From 697ec9fcd5ed4ed6f8ffc94d4f6401c55c872d58 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Tue, 28 Jul 2020 00:07:41 +0800 Subject: [PATCH 1/5] doc : update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b835889..6bf9b65 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ 系统初始化极度简单,只需要配置文件中,修改数据库连接,系统启动后会自动初始化数据库信息以及必须的基础数据 [在线文档国际](https://wenjianzhang.github.io/go-admin-site) + [在线文档国内](http://mydearzwj.gitee.io/go-admin-site/) [前端项目](https://github.com/wenjianzhang/go-admin-ui) From 980d0977fc42ad9fdb2815823da531b3b60f9c59 Mon Sep 17 00:00:00 2001 From: linwenxiang <991154416@qq.com> Date: Wed, 5 Aug 2020 21:05:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=BC=80=E6=94=BE=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=EF=BC=8C=E9=A1=B9=E7=9B=AE=E5=8F=AF=E4=BB=A5=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/run.go | 24 ++++++++++++++++++++++++ router/initrouter.go | 9 +++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 examples/run.go diff --git a/examples/run.go b/examples/run.go new file mode 100644 index 0000000..f663ff3 --- /dev/null +++ b/examples/run.go @@ -0,0 +1,24 @@ +package main + +import ( + "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" + "go-admin/global" + mycasbin "go-admin/pkg/casbin" + "go-admin/pkg/logger" + "go-admin/router" + "log" +) + +func main() { + var err error + global.Eloquent, err = gorm.Open("mysql", "root:123456@tcp/inmg?charset=utf8&parseTime=True&loc=Local") + if err != nil { + panic(err) + } + mycasbin.Setup() + logger.Setup() + global.GinEngine = gin.Default() + router.InitRouter() + log.Fatal(global.GinEngine.Run(":8000")) +} diff --git a/router/initrouter.go b/router/initrouter.go index 3fa54a2..87ec637 100644 --- a/router/initrouter.go +++ b/router/initrouter.go @@ -2,6 +2,7 @@ package router import ( "github.com/gin-gonic/gin" + "go-admin/global" "go-admin/handler" "go-admin/middleware" _ "go-admin/pkg/jwtauth" @@ -10,8 +11,12 @@ import ( ) func InitRouter() *gin.Engine { - - r := gin.New() + var r *gin.Engine + if global.GinEngine == nil { + r = gin.New() + } else { + r = global.GinEngine + } if config2.SslConfig.Enable { r.Use(handler.TlsHandler()) } From 18a2aeadaaaec522bdbc001a9e60c3f3d5bacb4e Mon Sep 17 00:00:00 2001 From: linwenxiang <991154416@qq.com> Date: Wed, 5 Aug 2020 23:22:09 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=92=8C=E9=98=9F=E5=88=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/cache/type.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pkg/cache/type.go diff --git a/pkg/cache/type.go b/pkg/cache/type.go new file mode 100644 index 0000000..5327760 --- /dev/null +++ b/pkg/cache/type.go @@ -0,0 +1,24 @@ +package cache + +import ( + "time" +) + +type Adapter interface { + Connect() + Get(key string) (string, error) + Set(key string, val interface{}, expire int) error + Del(key string) error + HashGet(hk, key string) (string, error) + HashDel(hk, key string) error + Increase(key string) error + Expire(key string, dur time.Duration) error + SetQueue(name string, message Message) error + GetQueue(name string, f func(message Message) error) +} + +type Message struct { + ID string + Stream string + Values map[string]interface{} +} From b9d30eee88e14b3d7fcf68b608cc4ec36608ad40 Mon Sep 17 00:00:00 2001 From: linwenxiang <991154416@qq.com> Date: Wed, 5 Aug 2020 23:30:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=92=8C=E9=98=9F=E5=88=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/cache/type.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cache/type.go b/pkg/cache/type.go index 5327760..e5844c9 100644 --- a/pkg/cache/type.go +++ b/pkg/cache/type.go @@ -17,8 +17,8 @@ type Adapter interface { GetQueue(name string, f func(message Message) error) } -type Message struct { - ID string - Stream string - Values map[string]interface{} +type Message interface { + SetID(string) + SetStream(string) + SetValue(map[string]interface{}) } From b57af6c5423af1cda0f9daf8dcb28c033bf0142d Mon Sep 17 00:00:00 2001 From: linwenxiang <991154416@qq.com> Date: Wed, 5 Aug 2020 23:31:01 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=92=8C=E9=98=9F=E5=88=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/cache/type.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/cache/type.go b/pkg/cache/type.go index e5844c9..e10941d 100644 --- a/pkg/cache/type.go +++ b/pkg/cache/type.go @@ -21,4 +21,7 @@ type Message interface { SetID(string) SetStream(string) SetValue(map[string]interface{}) + GetID() string + GetStream() string + GetValue() map[string]interface{} }