From 619ca1fde0f3ceec7181251756e82e1c1a5220f6 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 21 Jun 2023 14:12:50 +0800 Subject: [PATCH] fix --- server/canteen/internal/svc/servicecontext.go | 8 ++++++-- server/data-transfer/internal/svc/servicecontext.go | 8 ++++++-- server/map-library/internal/svc/servicecontext.go | 8 ++++++-- server/orders/internal/svc/servicecontext.go | 8 ++++++-- server/product-templatev2/internal/svc/servicecontext.go | 8 ++++++-- server/product/internal/svc/servicecontext.go | 8 ++++++-- .../internal/svc/servicecontext.go | 8 ++++++-- 7 files changed, 42 insertions(+), 14 deletions(-) diff --git a/server/canteen/internal/svc/servicecontext.go b/server/canteen/internal/svc/servicecontext.go index 482d13c6..dcd1d889 100644 --- a/server/canteen/internal/svc/servicecontext.go +++ b/server/canteen/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/canteen/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err)) diff --git a/server/data-transfer/internal/svc/servicecontext.go b/server/data-transfer/internal/svc/servicecontext.go index 795c0c3c..1a1a27a2 100644 --- a/server/data-transfer/internal/svc/servicecontext.go +++ b/server/data-transfer/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/data-transfer/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err)) diff --git a/server/map-library/internal/svc/servicecontext.go b/server/map-library/internal/svc/servicecontext.go index 29087239..ccf526be 100644 --- a/server/map-library/internal/svc/servicecontext.go +++ b/server/map-library/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/map-library/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err)) diff --git a/server/orders/internal/svc/servicecontext.go b/server/orders/internal/svc/servicecontext.go index 544a6191..99a7400a 100644 --- a/server/orders/internal/svc/servicecontext.go +++ b/server/orders/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/orders/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err)) diff --git a/server/product-templatev2/internal/svc/servicecontext.go b/server/product-templatev2/internal/svc/servicecontext.go index 76ee9a8e..b12e9921 100644 --- a/server/product-templatev2/internal/svc/servicecontext.go +++ b/server/product-templatev2/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/product-templatev2/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err)) diff --git a/server/product/internal/svc/servicecontext.go b/server/product/internal/svc/servicecontext.go index 300cfad0..b9157f3a 100644 --- a/server/product/internal/svc/servicecontext.go +++ b/server/product/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/product/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err)) diff --git a/server/shopping-cart-confirmation/internal/svc/servicecontext.go b/server/shopping-cart-confirmation/internal/svc/servicecontext.go index 35fd6c08..de8389d2 100644 --- a/server/shopping-cart-confirmation/internal/svc/servicecontext.go +++ b/server/shopping-cart-confirmation/internal/svc/servicecontext.go @@ -3,10 +3,12 @@ package svc import ( "errors" "fmt" - "fusenapi/initalize" "fusenapi/server/shopping-cart-confirmation/internal/config" "net/http" + "fusenapi/initalize" + "fusenapi/model/gmodel" + "github.com/golang-jwt/jwt" "gorm.io/gorm" ) @@ -15,6 +17,7 @@ type ServiceContext struct { Config config.Config MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { @@ -22,6 +25,7 @@ func NewServiceContext(c config.Config) *ServiceContext { return &ServiceContext{ Config: c, MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } @@ -37,7 +41,7 @@ func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, err return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) } // 返回用于验证签名的密钥 - return svcCtx.Config.Auth.AccessSecret, nil + return []byte(svcCtx.Config.Auth.AccessSecret), nil }) if err != nil { return nil, errors.New(fmt.Sprint("Error parsing token:", err))