Skip to content

Commit

Permalink
Merge pull request #30 from weiwiegeng/main
Browse files Browse the repository at this point in the history
 更新v2社区版docker compose
  • Loading branch information
xinjiayu authored Mar 6, 2024
2 parents 38b6fde + f186e44 commit 70715f6
Show file tree
Hide file tree
Showing 298 changed files with 657 additions and 651 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func RunServer(ctx context.Context, stopSignal chan os.Signal) {
service.Middleware().MiddlewareCORS,
service.Middleware().I18n,
)

service.SysToken().GfToken().Middleware(group)
router.System(ctx, group) //系统默认功能的路由
router.Iot(ctx, group) //Iot功能的路由
router.Analysis(ctx, group) //分析统计功能的路由
Expand Down
28 changes: 13 additions & 15 deletions internal/logic/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,23 @@ func (s *sMiddleware) Ctx(r *ghttp.Request) {
ctx := r.GetCtx()
r.SetCtx(r.GetNeverDoneCtx())

if r.GetHeader("Authorization") != "" {
// 初始化登录用户信息
data, err := service.SysToken().ParseToken(r)
// 初始化登录用户信息
data, err := service.SysToken().ParseToken(r)
if err != nil {
// 执行下一步请求逻辑
r.Middleware.Next()
}
if data != nil {
contextModel := new(model.Context)
err = gconv.Struct(data.Data, &contextModel.User)
//请求方式
contextModel.User.RequestWay = consts.TokenAuth
if err != nil {
g.Log().Error(ctx, err)
// 执行下一步请求逻辑
r.Middleware.Next()
}
if data != nil {
contextModel := new(model.Context)
err = gconv.Struct(data.Data, &contextModel.User)
//请求方式
contextModel.User.RequestWay = consts.TokenAuth
if err != nil {
g.Log().Error(ctx, err)
// 执行下一步请求逻辑
r.Middleware.Next()
}
service.Context().Init(r, contextModel)
}
service.Context().Init(r, contextModel)
}

// 执行下一步请求逻辑
Expand Down
10 changes: 5 additions & 5 deletions internal/logic/system/sys_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ var gftService = &gft{
lock: &sync.Mutex{},
}

func (m *sSysToken) GenerateToken(ctx context.Context, key string, data interface{}) (keys string, err error) {
keys, err = GfToken().GenerateToken(ctx, key, data)
func (s *sSysToken) GenerateToken(ctx context.Context, key string, data interface{}) (keys string, err error) {
keys, err = s.GfToken().GenerateToken(ctx, key, data)
return keys, err
}

func (m *sSysToken) ParseToken(r *ghttp.Request) (*gftoken.CustomClaims, error) {
return GfToken().ParseToken(r)
func (s *sSysToken) ParseToken(r *ghttp.Request) (*gftoken.CustomClaims, error) {
return s.GfToken().ParseToken(r)
}

func GfToken() *gftoken.GfToken {
func (s *sSysToken) GfToken() *gftoken.GfToken {
ctx := gctx.New()

//判断控制是否生效
Expand Down
905 changes: 453 additions & 452 deletions internal/service/system.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions manifest/config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ gfToken:
excludePaths: #排除不做登录验证的路由地址
- "/api/v1/login"
- "/api/v1/sysinfo"
- "/api/v1/captcha"

# 数据库连接配置
database:
Expand Down
1 change: 1 addition & 0 deletions manifest/docker-compose/iot-open/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ gfToken:
excludePaths: #排除不做登录验证的路由地址
- "/api/v1/login"
- "/api/v1/sysinfo"
- "/api/v1/captcha"

# 数据库连接配置
database:
Expand Down
2 changes: 1 addition & 1 deletion manifest/docker-compose/iot-open/iot-open.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
sagoo-iot-open:
image: sagoo-iot-open:1.0.2
image: sagoo-iot-open:1.0.4
restart: always
container_name: sagoo-iot-open
build:
Expand Down
Binary file modified manifest/docker-compose/iot-open/sagooiot
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 70715f6

Please sign in to comment.