From 440f13bee8fc8fd167a175b179fd2bb9ad8c9654 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 12:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=84=9F=E5=8A=A8=E4=B8=AD=E5=9B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_replica_id.sh | 0 goctl_template/api/context.tpl | 3 +-- goctl_template/api/handler.tpl | 2 +- .../internal/handler/acceptcookiehandler.go | 3 ++- .../handler/useremailconfirmationhandler.go | 2 +- .../handler/useremailregisterhandler.go | 2 +- .../handler/usergoogleloginhandler.go | 2 +- .../auth/internal/handler/userloginhandler.go | 2 +- server/auth/internal/svc/servicecontext.go | 5 ++--- .../handler/getcanteendetailhandler.go | 2 +- .../handler/savecanteentypeproducthandler.go | 2 +- server/canteen/internal/svc/servicecontext.go | 5 ++--- .../handler/getqrcodesetlisthandler.go | 2 +- .../handler/getstandardlogolisthandler.go | 2 +- .../internal/svc/servicecontext.go | 5 ++--- .../internal/handler/useraddaddresshandler.go | 2 +- .../handler/useraddresslisthandler.go | 2 +- .../internal/handler/useragainorderhandler.go | 2 +- .../internal/handler/userbasicinfohandler.go | 2 +- .../handler/usercontactservicehandler.go | 2 +- .../internal/handler/userfontshandler.go | 2 +- .../internal/handler/usergettypehandler.go | 2 +- .../internal/handler/userlogolisthandler.go | 2 +- .../internal/handler/useroderdeletehandler.go | 2 +- .../handler/userordercancelhandler.go | 2 +- .../handler/userorderdeletehandler.go | 2 +- .../internal/handler/userorderlisthandler.go | 2 +- .../handler/usersavebasicinfohandler.go | 2 +- .../handler/userstatusconfighandler.go | 2 +- .../internal/svc/servicecontext.go | 5 ++--- server/inventory/etc/inventory.yaml | 1 + .../internal/handler/getcloudlisthandler.go | 2 +- .../internal/handler/getpickuplisthandler.go | 2 +- .../internal/handler/supplementhandler.go | 2 +- .../inventory/internal/handler/takehandler.go | 2 +- .../inventory/internal/svc/servicecontext.go | 5 ++--- .../handler/getmaplibrarylisthandler.go | 2 +- .../internal/handler/savemaplibraryhandler.go | 2 +- .../internal/svc/servicecontext.go | 5 ++--- .../internal/handler/getorderdetailhandler.go | 2 +- .../handler/getorderinvoicehandler.go | 2 +- server/orders/internal/svc/servicecontext.go | 5 ++--- server/pay/etc/pay.yaml | 1 + .../handler/orderpaymentintenthandler.go | 2 +- .../internal/handler/orderrefundhandler.go | 2 +- .../internal/handler/stripewebhookhandler.go | 2 +- server/pay/internal/svc/servicecontext.go | 5 ++--- .../handler/getproducttemplatetagshandler.go | 2 +- .../internal/svc/servicecontext.go | 5 ++--- .../internal/handler/designgatherhandler.go | 2 +- .../handler/getfittingbypidhandler.go | 2 +- .../handler/getlastproductdesignhandler.go | 2 +- .../internal/handler/getlightbypidhandler.go | 2 +- .../internal/handler/getmodelbypidhandler.go | 2 +- .../internal/handler/getpricebypidhandler.go | 2 +- .../handler/getproductdesignhandler.go | 2 +- .../internal/handler/getproductinfohandler.go | 2 +- .../internal/handler/getproductlisthandler.go | 2 +- .../handler/getrecommandproductlisthandler.go | 2 +- .../handler/getrenderdesignhandler.go | 2 +- .../handler/getrendersettingbypidhandler.go | 2 +- .../internal/handler/getsizebypidhandler.go | 2 +- .../handler/getsizebyproducthandler.go | 2 +- .../handler/getsuccessrecommandhandler.go | 2 +- .../handler/gettagproductlisthandler.go | 2 +- .../handler/gettemplatebypidhandler.go | 2 +- .../homepagerecommendproductlisthandler.go | 2 +- .../handler/otherproductlisthandler.go | 2 +- .../internal/handler/savedesignhandler.go | 2 +- server/render/etc/render.yaml | 1 + .../internal/handler/getfaceslicehandler.go | 2 +- .../internal/handler/rendernotifyhandler.go | 2 +- server/render/internal/svc/servicecontext.go | 5 ++--- server/resource/etc/resource.yaml | 1 + .../internal/handler/logocombinehandler.go | 2 +- .../internal/handler/resourceinfohandler.go | 2 +- .../etc/shopping-cart-confirmation.yaml | 2 +- .../internal/handler/cartaddhandler.go | 2 +- .../internal/handler/cartdeletehandler.go | 2 +- .../internal/handler/cartlisthandler.go | 2 +- .../internal/handler/cartnumberhandler.go | 2 +- .../handler/cartorderdetailhandler.go | 2 +- .../handler/changeordermethodhandler.go | 2 +- .../internal/handler/createorderhandler.go | 2 +- .../internal/svc/servicecontext.go | 5 ++--- server/upload/etc/upload.yaml | 2 +- .../internal/handler/uploadcallbackhandler.go | 2 +- .../internal/handler/uploadfilebasehandler.go | 2 +- .../handler/uploadfilefrontendhandler.go | 2 +- .../handler/uploadfilesbackendhandler.go | 2 +- .../handler/uploadfilesfrontendhandler.go | 2 +- .../internal/handler/uploadlogohandler.go | 2 +- .../internal/handler/uploadqrcodehandler.go | 2 +- .../internal/handler/uploadupfilehandler.go | 2 +- server/webset/etc/webset.yaml | 2 +- .../internal/handler/websetsettinghandler.go | 2 +- server/webset/internal/svc/servicecontext.go | 5 ++--- server/websocket/etc/websocket.yaml | 2 +- .../websocket/internal/svc/servicecontext.go | 7 +++---- shared/main.go | 4 +++- shared/shared_state.go | 21 +++++++++++++++++++ utils/basic/request_parse.go | 11 ++++++++-- 102 files changed, 146 insertions(+), 125 deletions(-) mode change 100644 => 100755 config_replica_id.sh diff --git a/config_replica_id.sh b/config_replica_id.sh old mode 100644 new mode 100755 diff --git a/goctl_template/api/context.tpl b/goctl_template/api/context.tpl index e061f249..f90ebc50 100644 --- a/goctl_template/api/context.tpl +++ b/goctl_template/api/context.tpl @@ -26,12 +26,11 @@ type ServiceContext struct { func NewServiceContext(c {{.config}}) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), RabbitMq:initalize.InitRabbitMq(c.SourceRabbitMq, nil), {{.middlewareAssignment}} diff --git a/goctl_template/api/handler.tpl b/goctl_template/api/handler.tpl index f15cc2ff..604bf136 100644 --- a/goctl_template/api/handler.tpl +++ b/goctl_template/api/handler.tpl @@ -13,7 +13,7 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { {{if .HasRequest}}var req types.{{.RequestType}} - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/auth/internal/handler/acceptcookiehandler.go b/server/auth/internal/handler/acceptcookiehandler.go index fdb176a4..b4a72d6f 100644 --- a/server/auth/internal/handler/acceptcookiehandler.go +++ b/server/auth/internal/handler/acceptcookiehandler.go @@ -15,7 +15,8 @@ func AcceptCookieHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/auth/internal/handler/useremailconfirmationhandler.go b/server/auth/internal/handler/useremailconfirmationhandler.go index 60e3a340..2b6db3df 100644 --- a/server/auth/internal/handler/useremailconfirmationhandler.go +++ b/server/auth/internal/handler/useremailconfirmationhandler.go @@ -15,7 +15,7 @@ func UserEmailConfirmationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestEmailConfirmation - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/auth/internal/handler/useremailregisterhandler.go b/server/auth/internal/handler/useremailregisterhandler.go index 9c21ff65..bf073982 100644 --- a/server/auth/internal/handler/useremailregisterhandler.go +++ b/server/auth/internal/handler/useremailregisterhandler.go @@ -15,7 +15,7 @@ func UserEmailRegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestEmailRegister - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/auth/internal/handler/usergoogleloginhandler.go b/server/auth/internal/handler/usergoogleloginhandler.go index 022b684c..fd1f54f6 100644 --- a/server/auth/internal/handler/usergoogleloginhandler.go +++ b/server/auth/internal/handler/usergoogleloginhandler.go @@ -15,7 +15,7 @@ func UserGoogleLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestGoogleLogin - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/auth/internal/handler/userloginhandler.go b/server/auth/internal/handler/userloginhandler.go index 4e1c75b7..2e32b702 100644 --- a/server/auth/internal/handler/userloginhandler.go +++ b/server/auth/internal/handler/userloginhandler.go @@ -15,7 +15,7 @@ func UserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestUserLogin - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/auth/internal/svc/servicecontext.go b/server/auth/internal/svc/servicecontext.go index bd2be563..837371be 100644 --- a/server/auth/internal/svc/servicecontext.go +++ b/server/auth/internal/svc/servicecontext.go @@ -6,7 +6,6 @@ import ( "fusenapi/server/auth/internal/config" "fusenapi/shared" "fusenapi/utils/auth" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -28,12 +27,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), TokenManger: auth.NewConfirmationLink[auth.RegisterToken](c.Auth.AccessSecret, "http://localhost:9900/api/auth/oauth2/register"), } diff --git a/server/canteen/internal/handler/getcanteendetailhandler.go b/server/canteen/internal/handler/getcanteendetailhandler.go index 53b23ef0..81ac03df 100644 --- a/server/canteen/internal/handler/getcanteendetailhandler.go +++ b/server/canteen/internal/handler/getcanteendetailhandler.go @@ -15,7 +15,7 @@ func GetCanteenDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetCanteenDetailReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/canteen/internal/handler/savecanteentypeproducthandler.go b/server/canteen/internal/handler/savecanteentypeproducthandler.go index 2951d0a7..5ca34dda 100644 --- a/server/canteen/internal/handler/savecanteentypeproducthandler.go +++ b/server/canteen/internal/handler/savecanteentypeproducthandler.go @@ -15,7 +15,7 @@ func SaveCanteenTypeProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc return func(w http.ResponseWriter, r *http.Request) { var req types.SaveCanteenTypeProductReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/canteen/internal/svc/servicecontext.go b/server/canteen/internal/svc/servicecontext.go index e70048f5..f4a654ba 100644 --- a/server/canteen/internal/svc/servicecontext.go +++ b/server/canteen/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/canteen/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/data-transfer/internal/handler/getqrcodesetlisthandler.go b/server/data-transfer/internal/handler/getqrcodesetlisthandler.go index e19b370d..050c768c 100644 --- a/server/data-transfer/internal/handler/getqrcodesetlisthandler.go +++ b/server/data-transfer/internal/handler/getqrcodesetlisthandler.go @@ -15,7 +15,7 @@ func GetQrCodeSetListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/data-transfer/internal/handler/getstandardlogolisthandler.go b/server/data-transfer/internal/handler/getstandardlogolisthandler.go index 59ff5668..db38259d 100644 --- a/server/data-transfer/internal/handler/getstandardlogolisthandler.go +++ b/server/data-transfer/internal/handler/getstandardlogolisthandler.go @@ -15,7 +15,7 @@ func GetStandardLogoListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/data-transfer/internal/svc/servicecontext.go b/server/data-transfer/internal/svc/servicecontext.go index 2cfc4926..a72b0ce0 100644 --- a/server/data-transfer/internal/svc/servicecontext.go +++ b/server/data-transfer/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/data-transfer/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/home-user-auth/internal/handler/useraddaddresshandler.go b/server/home-user-auth/internal/handler/useraddaddresshandler.go index 07694bbf..84354a6d 100644 --- a/server/home-user-auth/internal/handler/useraddaddresshandler.go +++ b/server/home-user-auth/internal/handler/useraddaddresshandler.go @@ -15,7 +15,7 @@ func UserAddAddressHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestAddAddress - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/useraddresslisthandler.go b/server/home-user-auth/internal/handler/useraddresslisthandler.go index 0a7245f2..9060da40 100644 --- a/server/home-user-auth/internal/handler/useraddresslisthandler.go +++ b/server/home-user-auth/internal/handler/useraddresslisthandler.go @@ -15,7 +15,7 @@ func UserAddressListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/useragainorderhandler.go b/server/home-user-auth/internal/handler/useragainorderhandler.go index d97c2b08..4bf584e7 100644 --- a/server/home-user-auth/internal/handler/useragainorderhandler.go +++ b/server/home-user-auth/internal/handler/useragainorderhandler.go @@ -15,7 +15,7 @@ func UserAgainOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UserAgainOrderReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userbasicinfohandler.go b/server/home-user-auth/internal/handler/userbasicinfohandler.go index bb7fdff5..85e7ca17 100644 --- a/server/home-user-auth/internal/handler/userbasicinfohandler.go +++ b/server/home-user-auth/internal/handler/userbasicinfohandler.go @@ -15,7 +15,7 @@ func UserBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/usercontactservicehandler.go b/server/home-user-auth/internal/handler/usercontactservicehandler.go index c215a6c1..511d170f 100644 --- a/server/home-user-auth/internal/handler/usercontactservicehandler.go +++ b/server/home-user-auth/internal/handler/usercontactservicehandler.go @@ -15,7 +15,7 @@ func UserContactServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestContactService - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userfontshandler.go b/server/home-user-auth/internal/handler/userfontshandler.go index 2c88d00e..a98156e2 100644 --- a/server/home-user-auth/internal/handler/userfontshandler.go +++ b/server/home-user-auth/internal/handler/userfontshandler.go @@ -15,7 +15,7 @@ func UserFontsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/usergettypehandler.go b/server/home-user-auth/internal/handler/usergettypehandler.go index 493cf142..9558f557 100644 --- a/server/home-user-auth/internal/handler/usergettypehandler.go +++ b/server/home-user-auth/internal/handler/usergettypehandler.go @@ -15,7 +15,7 @@ func UserGetTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userlogolisthandler.go b/server/home-user-auth/internal/handler/userlogolisthandler.go index 4774154d..873ab4d5 100644 --- a/server/home-user-auth/internal/handler/userlogolisthandler.go +++ b/server/home-user-auth/internal/handler/userlogolisthandler.go @@ -15,7 +15,7 @@ func UserLogoListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UserLogoListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/useroderdeletehandler.go b/server/home-user-auth/internal/handler/useroderdeletehandler.go index 2b80fe78..91cd7501 100644 --- a/server/home-user-auth/internal/handler/useroderdeletehandler.go +++ b/server/home-user-auth/internal/handler/useroderdeletehandler.go @@ -15,7 +15,7 @@ func UserOderDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestOrderId - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userordercancelhandler.go b/server/home-user-auth/internal/handler/userordercancelhandler.go index cdba1878..65402d98 100644 --- a/server/home-user-auth/internal/handler/userordercancelhandler.go +++ b/server/home-user-auth/internal/handler/userordercancelhandler.go @@ -15,7 +15,7 @@ func UserOrderCancelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UserOrderCancelReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userorderdeletehandler.go b/server/home-user-auth/internal/handler/userorderdeletehandler.go index c5361fc5..4b4ca392 100644 --- a/server/home-user-auth/internal/handler/userorderdeletehandler.go +++ b/server/home-user-auth/internal/handler/userorderdeletehandler.go @@ -15,7 +15,7 @@ func UserOrderDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UserOrderDeleteReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userorderlisthandler.go b/server/home-user-auth/internal/handler/userorderlisthandler.go index ace3895b..f59f11da 100644 --- a/server/home-user-auth/internal/handler/userorderlisthandler.go +++ b/server/home-user-auth/internal/handler/userorderlisthandler.go @@ -15,7 +15,7 @@ func UserOrderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UserOrderListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/usersavebasicinfohandler.go b/server/home-user-auth/internal/handler/usersavebasicinfohandler.go index 8785a37a..c29d60ab 100644 --- a/server/home-user-auth/internal/handler/usersavebasicinfohandler.go +++ b/server/home-user-auth/internal/handler/usersavebasicinfohandler.go @@ -15,7 +15,7 @@ func UserSaveBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestBasicInfoForm - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/handler/userstatusconfighandler.go b/server/home-user-auth/internal/handler/userstatusconfighandler.go index 953a6bc8..bb70d0d3 100644 --- a/server/home-user-auth/internal/handler/userstatusconfighandler.go +++ b/server/home-user-auth/internal/handler/userstatusconfighandler.go @@ -15,7 +15,7 @@ func UserStatusConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/home-user-auth/internal/svc/servicecontext.go b/server/home-user-auth/internal/svc/servicecontext.go index 9acce867..ac309bbc 100644 --- a/server/home-user-auth/internal/svc/servicecontext.go +++ b/server/home-user-auth/internal/svc/servicecontext.go @@ -4,7 +4,6 @@ import ( "fusenapi/initalize" "fusenapi/model/gmodel" "fusenapi/shared" - "fusenapi/utils/autoconfig" "github.com/golang-jwt/jwt" "gorm.io/gorm" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/inventory/etc/inventory.yaml b/server/inventory/etc/inventory.yaml index decc2507..9b76f174 100644 --- a/server/inventory/etc/inventory.yaml +++ b/server/inventory/etc/inventory.yaml @@ -1,6 +1,7 @@ Name: inventory Host: localhost Port: 9905 +ReplicaId: 30 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/inventory/internal/handler/getcloudlisthandler.go b/server/inventory/internal/handler/getcloudlisthandler.go index c6b5badc..90708969 100644 --- a/server/inventory/internal/handler/getcloudlisthandler.go +++ b/server/inventory/internal/handler/getcloudlisthandler.go @@ -15,7 +15,7 @@ func GetCloudListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetCloudListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/inventory/internal/handler/getpickuplisthandler.go b/server/inventory/internal/handler/getpickuplisthandler.go index b4eb83a3..ffe7fb4f 100644 --- a/server/inventory/internal/handler/getpickuplisthandler.go +++ b/server/inventory/internal/handler/getpickuplisthandler.go @@ -15,7 +15,7 @@ func GetPickupListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetPickupListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/inventory/internal/handler/supplementhandler.go b/server/inventory/internal/handler/supplementhandler.go index ec762bf1..67bf8cd0 100644 --- a/server/inventory/internal/handler/supplementhandler.go +++ b/server/inventory/internal/handler/supplementhandler.go @@ -15,7 +15,7 @@ func SupplementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.SupplementReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/inventory/internal/handler/takehandler.go b/server/inventory/internal/handler/takehandler.go index b2037459..bb1d285c 100644 --- a/server/inventory/internal/handler/takehandler.go +++ b/server/inventory/internal/handler/takehandler.go @@ -15,7 +15,7 @@ func TakeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.TakeReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/inventory/internal/svc/servicecontext.go b/server/inventory/internal/svc/servicecontext.go index 18251bcc..145724b4 100644 --- a/server/inventory/internal/svc/servicecontext.go +++ b/server/inventory/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/inventory/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/map-library/internal/handler/getmaplibrarylisthandler.go b/server/map-library/internal/handler/getmaplibrarylisthandler.go index 9de7cad4..4b75d285 100644 --- a/server/map-library/internal/handler/getmaplibrarylisthandler.go +++ b/server/map-library/internal/handler/getmaplibrarylisthandler.go @@ -15,7 +15,7 @@ func GetMapLibraryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/map-library/internal/handler/savemaplibraryhandler.go b/server/map-library/internal/handler/savemaplibraryhandler.go index 568ad1b4..952b2877 100644 --- a/server/map-library/internal/handler/savemaplibraryhandler.go +++ b/server/map-library/internal/handler/savemaplibraryhandler.go @@ -15,7 +15,7 @@ func SaveMapLibraryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/map-library/internal/svc/servicecontext.go b/server/map-library/internal/svc/servicecontext.go index 9b25dd0c..fdaa617f 100644 --- a/server/map-library/internal/svc/servicecontext.go +++ b/server/map-library/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/map-library/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/orders/internal/handler/getorderdetailhandler.go b/server/orders/internal/handler/getorderdetailhandler.go index b7b9f827..8423debc 100644 --- a/server/orders/internal/handler/getorderdetailhandler.go +++ b/server/orders/internal/handler/getorderdetailhandler.go @@ -15,7 +15,7 @@ func GetOrderDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetOrderDetailReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/orders/internal/handler/getorderinvoicehandler.go b/server/orders/internal/handler/getorderinvoicehandler.go index 3e071f12..4135c24f 100644 --- a/server/orders/internal/handler/getorderinvoicehandler.go +++ b/server/orders/internal/handler/getorderinvoicehandler.go @@ -15,7 +15,7 @@ func GetOrderInvoiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetOrderInvoiceReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/orders/internal/svc/servicecontext.go b/server/orders/internal/svc/servicecontext.go index 6e07178e..3502a601 100644 --- a/server/orders/internal/svc/servicecontext.go +++ b/server/orders/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/orders/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/pay/etc/pay.yaml b/server/pay/etc/pay.yaml index 831292a9..9d692015 100644 --- a/server/pay/etc/pay.yaml +++ b/server/pay/etc/pay.yaml @@ -1,6 +1,7 @@ Name: pay Host: 0.0.0.0 Port: 9915 +ReplicaId: 45 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/pay/internal/handler/orderpaymentintenthandler.go b/server/pay/internal/handler/orderpaymentintenthandler.go index 087d4e0e..d252d73c 100644 --- a/server/pay/internal/handler/orderpaymentintenthandler.go +++ b/server/pay/internal/handler/orderpaymentintenthandler.go @@ -15,7 +15,7 @@ func OrderPaymentIntentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.OrderPaymentIntentReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/pay/internal/handler/orderrefundhandler.go b/server/pay/internal/handler/orderrefundhandler.go index 697fe416..3d7998ff 100644 --- a/server/pay/internal/handler/orderrefundhandler.go +++ b/server/pay/internal/handler/orderrefundhandler.go @@ -15,7 +15,7 @@ func OrderRefundHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.OrderRefundReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/pay/internal/handler/stripewebhookhandler.go b/server/pay/internal/handler/stripewebhookhandler.go index 7a679aee..ca7689d0 100644 --- a/server/pay/internal/handler/stripewebhookhandler.go +++ b/server/pay/internal/handler/stripewebhookhandler.go @@ -25,7 +25,7 @@ func StripeWebhookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { var req types.StripeWebhookReq - // userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + // userinfo, err := basic.RequestParse(w, r, svcCtx, &req) // if err != nil { // return // } diff --git a/server/pay/internal/svc/servicecontext.go b/server/pay/internal/svc/servicecontext.go index 146721fd..9eca2703 100644 --- a/server/pay/internal/svc/servicecontext.go +++ b/server/pay/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/pay/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/product-template-tag/internal/handler/getproducttemplatetagshandler.go b/server/product-template-tag/internal/handler/getproducttemplatetagshandler.go index ab38fee3..cf7cf96e 100644 --- a/server/product-template-tag/internal/handler/getproducttemplatetagshandler.go +++ b/server/product-template-tag/internal/handler/getproducttemplatetagshandler.go @@ -15,7 +15,7 @@ func GetProductTemplateTagsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc return func(w http.ResponseWriter, r *http.Request) { var req types.GetProductTemplateTagsReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product-template-tag/internal/svc/servicecontext.go b/server/product-template-tag/internal/svc/servicecontext.go index e5976906..4491d5f5 100644 --- a/server/product-template-tag/internal/svc/servicecontext.go +++ b/server/product-template-tag/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/product-template-tag/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/product/internal/handler/designgatherhandler.go b/server/product/internal/handler/designgatherhandler.go index fd80598e..5108a59d 100644 --- a/server/product/internal/handler/designgatherhandler.go +++ b/server/product/internal/handler/designgatherhandler.go @@ -15,7 +15,7 @@ func DesignGatherHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.DesignGatherReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getfittingbypidhandler.go b/server/product/internal/handler/getfittingbypidhandler.go index 65e419d3..8c48642c 100644 --- a/server/product/internal/handler/getfittingbypidhandler.go +++ b/server/product/internal/handler/getfittingbypidhandler.go @@ -15,7 +15,7 @@ func GetFittingByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetFittingByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getlastproductdesignhandler.go b/server/product/internal/handler/getlastproductdesignhandler.go index a99f5345..e2f656a8 100644 --- a/server/product/internal/handler/getlastproductdesignhandler.go +++ b/server/product/internal/handler/getlastproductdesignhandler.go @@ -15,7 +15,7 @@ func GetLastProductDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getlightbypidhandler.go b/server/product/internal/handler/getlightbypidhandler.go index 85f77bb7..2763fabd 100644 --- a/server/product/internal/handler/getlightbypidhandler.go +++ b/server/product/internal/handler/getlightbypidhandler.go @@ -15,7 +15,7 @@ func GetLightByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetLightByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getmodelbypidhandler.go b/server/product/internal/handler/getmodelbypidhandler.go index 1ffe24b3..8457bd0c 100644 --- a/server/product/internal/handler/getmodelbypidhandler.go +++ b/server/product/internal/handler/getmodelbypidhandler.go @@ -15,7 +15,7 @@ func GetModelByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetModelByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getpricebypidhandler.go b/server/product/internal/handler/getpricebypidhandler.go index 36b24db2..254799fe 100644 --- a/server/product/internal/handler/getpricebypidhandler.go +++ b/server/product/internal/handler/getpricebypidhandler.go @@ -15,7 +15,7 @@ func GetPriceByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetPriceByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getproductdesignhandler.go b/server/product/internal/handler/getproductdesignhandler.go index 4db37619..42862fb8 100644 --- a/server/product/internal/handler/getproductdesignhandler.go +++ b/server/product/internal/handler/getproductdesignhandler.go @@ -15,7 +15,7 @@ func GetProductDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetProductDesignReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getproductinfohandler.go b/server/product/internal/handler/getproductinfohandler.go index f936d053..e195b2c1 100644 --- a/server/product/internal/handler/getproductinfohandler.go +++ b/server/product/internal/handler/getproductinfohandler.go @@ -15,7 +15,7 @@ func GetProductInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetProductInfoReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getproductlisthandler.go b/server/product/internal/handler/getproductlisthandler.go index 63c0e6ba..41360ef6 100644 --- a/server/product/internal/handler/getproductlisthandler.go +++ b/server/product/internal/handler/getproductlisthandler.go @@ -15,7 +15,7 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetProductListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getrecommandproductlisthandler.go b/server/product/internal/handler/getrecommandproductlisthandler.go index cb6c808a..332ece32 100644 --- a/server/product/internal/handler/getrecommandproductlisthandler.go +++ b/server/product/internal/handler/getrecommandproductlisthandler.go @@ -15,7 +15,7 @@ func GetRecommandProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc return func(w http.ResponseWriter, r *http.Request) { var req types.GetRecommandProductListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getrenderdesignhandler.go b/server/product/internal/handler/getrenderdesignhandler.go index 92948ba9..967f7d05 100644 --- a/server/product/internal/handler/getrenderdesignhandler.go +++ b/server/product/internal/handler/getrenderdesignhandler.go @@ -15,7 +15,7 @@ func GetRenderDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetRenderDesignReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getrendersettingbypidhandler.go b/server/product/internal/handler/getrendersettingbypidhandler.go index 7e332d01..d6802345 100644 --- a/server/product/internal/handler/getrendersettingbypidhandler.go +++ b/server/product/internal/handler/getrendersettingbypidhandler.go @@ -15,7 +15,7 @@ func GetRenderSettingByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetRenderSettingByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getsizebypidhandler.go b/server/product/internal/handler/getsizebypidhandler.go index 08034542..a17f18e8 100644 --- a/server/product/internal/handler/getsizebypidhandler.go +++ b/server/product/internal/handler/getsizebypidhandler.go @@ -15,7 +15,7 @@ func GetSizeByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetSizeByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getsizebyproducthandler.go b/server/product/internal/handler/getsizebyproducthandler.go index 4fa7dd92..0451933b 100644 --- a/server/product/internal/handler/getsizebyproducthandler.go +++ b/server/product/internal/handler/getsizebyproducthandler.go @@ -15,7 +15,7 @@ func GetSizeByProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/getsuccessrecommandhandler.go b/server/product/internal/handler/getsuccessrecommandhandler.go index aa83b742..63bdeae3 100644 --- a/server/product/internal/handler/getsuccessrecommandhandler.go +++ b/server/product/internal/handler/getsuccessrecommandhandler.go @@ -15,7 +15,7 @@ func GetSuccessRecommandHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetSuccessRecommandReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/gettagproductlisthandler.go b/server/product/internal/handler/gettagproductlisthandler.go index 0eca23df..199c0f01 100644 --- a/server/product/internal/handler/gettagproductlisthandler.go +++ b/server/product/internal/handler/gettagproductlisthandler.go @@ -15,7 +15,7 @@ func GetTagProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetTagProductListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/gettemplatebypidhandler.go b/server/product/internal/handler/gettemplatebypidhandler.go index 78306692..9dc538ea 100644 --- a/server/product/internal/handler/gettemplatebypidhandler.go +++ b/server/product/internal/handler/gettemplatebypidhandler.go @@ -15,7 +15,7 @@ func GetTemplateByPidHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.GetTemplateByPidReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/homepagerecommendproductlisthandler.go b/server/product/internal/handler/homepagerecommendproductlisthandler.go index f3f8d575..1cad5f91 100644 --- a/server/product/internal/handler/homepagerecommendproductlisthandler.go +++ b/server/product/internal/handler/homepagerecommendproductlisthandler.go @@ -15,7 +15,7 @@ func HomePageRecommendProductListHandler(svcCtx *svc.ServiceContext) http.Handle return func(w http.ResponseWriter, r *http.Request) { var req types.HomePageRecommendProductListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/otherproductlisthandler.go b/server/product/internal/handler/otherproductlisthandler.go index 579e7519..e5ad758b 100644 --- a/server/product/internal/handler/otherproductlisthandler.go +++ b/server/product/internal/handler/otherproductlisthandler.go @@ -15,7 +15,7 @@ func OtherProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.OtherProductListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/product/internal/handler/savedesignhandler.go b/server/product/internal/handler/savedesignhandler.go index 437b86fc..51249a28 100644 --- a/server/product/internal/handler/savedesignhandler.go +++ b/server/product/internal/handler/savedesignhandler.go @@ -15,7 +15,7 @@ func SaveDesignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.SaveDesignReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/render/etc/render.yaml b/server/render/etc/render.yaml index 86b2a6a1..2964916f 100644 --- a/server/render/etc/render.yaml +++ b/server/render/etc/render.yaml @@ -1,6 +1,7 @@ Name: render Host: 0.0.0.0 Port: 9919 +ReplicaId: 55 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/render/internal/handler/getfaceslicehandler.go b/server/render/internal/handler/getfaceslicehandler.go index ed02f39e..ac337bb0 100644 --- a/server/render/internal/handler/getfaceslicehandler.go +++ b/server/render/internal/handler/getfaceslicehandler.go @@ -15,7 +15,7 @@ func GetFaceSliceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/render/internal/handler/rendernotifyhandler.go b/server/render/internal/handler/rendernotifyhandler.go index e746e1a9..a8d01c9c 100644 --- a/server/render/internal/handler/rendernotifyhandler.go +++ b/server/render/internal/handler/rendernotifyhandler.go @@ -15,7 +15,7 @@ func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RenderNotifyReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/render/internal/svc/servicecontext.go b/server/render/internal/svc/servicecontext.go index 752222c0..818ad8c9 100644 --- a/server/render/internal/svc/servicecontext.go +++ b/server/render/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/render/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "github.com/aws/aws-sdk-go/aws" @@ -31,14 +30,14 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) config := aws.Config{ Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token), } return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), AwsSession: session.Must(session.NewSession(&config)), diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index b57c5f1c..5af90672 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -1,6 +1,7 @@ Name: resource Host: 0.0.0.0 Port: 9916 +ReplicaId: 60 Timeout: 15000 #服务超时时间(毫秒) SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: diff --git a/server/resource/internal/handler/logocombinehandler.go b/server/resource/internal/handler/logocombinehandler.go index fd2801b4..23c1589c 100644 --- a/server/resource/internal/handler/logocombinehandler.go +++ b/server/resource/internal/handler/logocombinehandler.go @@ -15,7 +15,7 @@ func LogoCombineHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.LogoCombineReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/resource/internal/handler/resourceinfohandler.go b/server/resource/internal/handler/resourceinfohandler.go index b358e31e..14b39d98 100644 --- a/server/resource/internal/handler/resourceinfohandler.go +++ b/server/resource/internal/handler/resourceinfohandler.go @@ -15,7 +15,7 @@ func ResourceInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.ResourceInfoReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml index f9fba524..85de100c 100644 --- a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml +++ b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml @@ -1,7 +1,7 @@ Name: shopping-cart-confirmation Host: localhost Port: 9911 -ReplicaId: 60 +ReplicaId: 65 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/shopping-cart-confirmation/internal/handler/cartaddhandler.go b/server/shopping-cart-confirmation/internal/handler/cartaddhandler.go index 9ec6d0a0..b09b01e4 100644 --- a/server/shopping-cart-confirmation/internal/handler/cartaddhandler.go +++ b/server/shopping-cart-confirmation/internal/handler/cartaddhandler.go @@ -15,7 +15,7 @@ func CartAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.CartAddReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/handler/cartdeletehandler.go b/server/shopping-cart-confirmation/internal/handler/cartdeletehandler.go index ac3d2ea2..47cc9f8a 100644 --- a/server/shopping-cart-confirmation/internal/handler/cartdeletehandler.go +++ b/server/shopping-cart-confirmation/internal/handler/cartdeletehandler.go @@ -15,7 +15,7 @@ func CartDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.CartDeleteReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go b/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go index d61c0386..1066bc19 100644 --- a/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go +++ b/server/shopping-cart-confirmation/internal/handler/cartlisthandler.go @@ -15,7 +15,7 @@ func CartListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.CartListReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/handler/cartnumberhandler.go b/server/shopping-cart-confirmation/internal/handler/cartnumberhandler.go index 41e437eb..4ff7632d 100644 --- a/server/shopping-cart-confirmation/internal/handler/cartnumberhandler.go +++ b/server/shopping-cart-confirmation/internal/handler/cartnumberhandler.go @@ -15,7 +15,7 @@ func CartNumberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.Request - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/handler/cartorderdetailhandler.go b/server/shopping-cart-confirmation/internal/handler/cartorderdetailhandler.go index 8f52a617..94b4b738 100644 --- a/server/shopping-cart-confirmation/internal/handler/cartorderdetailhandler.go +++ b/server/shopping-cart-confirmation/internal/handler/cartorderdetailhandler.go @@ -15,7 +15,7 @@ func CartOrderDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.CartOrderDetailReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/handler/changeordermethodhandler.go b/server/shopping-cart-confirmation/internal/handler/changeordermethodhandler.go index 17be550a..dc8d6ec4 100644 --- a/server/shopping-cart-confirmation/internal/handler/changeordermethodhandler.go +++ b/server/shopping-cart-confirmation/internal/handler/changeordermethodhandler.go @@ -15,7 +15,7 @@ func ChangeOrderMethodHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.ChangeOrderMethodReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/handler/createorderhandler.go b/server/shopping-cart-confirmation/internal/handler/createorderhandler.go index 3052e598..8ecb0f07 100644 --- a/server/shopping-cart-confirmation/internal/handler/createorderhandler.go +++ b/server/shopping-cart-confirmation/internal/handler/createorderhandler.go @@ -15,7 +15,7 @@ func CreateOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.CreateOrderReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/shopping-cart-confirmation/internal/svc/servicecontext.go b/server/shopping-cart-confirmation/internal/svc/servicecontext.go index 35bd8a39..636e56f7 100644 --- a/server/shopping-cart-confirmation/internal/svc/servicecontext.go +++ b/server/shopping-cart-confirmation/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/shopping-cart-confirmation/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 3c64b293..40204d83 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -1,7 +1,7 @@ Name: upload Host: localhost Port: 9912 -ReplicaId: 65 +ReplicaId: 70 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Env: "test" Auth: diff --git a/server/upload/internal/handler/uploadcallbackhandler.go b/server/upload/internal/handler/uploadcallbackhandler.go index 4b72d49a..3882a06b 100644 --- a/server/upload/internal/handler/uploadcallbackhandler.go +++ b/server/upload/internal/handler/uploadcallbackhandler.go @@ -15,7 +15,7 @@ func UploadCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UploadCallbackReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadfilebasehandler.go b/server/upload/internal/handler/uploadfilebasehandler.go index 72452b27..cbadbc88 100644 --- a/server/upload/internal/handler/uploadfilebasehandler.go +++ b/server/upload/internal/handler/uploadfilebasehandler.go @@ -16,7 +16,7 @@ func UploadFileBaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { // data, _ := io.ReadAll(r.Body) // log.Println(string(data)) var req types.UploadFileBaseReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadfilefrontendhandler.go b/server/upload/internal/handler/uploadfilefrontendhandler.go index 2caba621..f70b1e96 100644 --- a/server/upload/internal/handler/uploadfilefrontendhandler.go +++ b/server/upload/internal/handler/uploadfilefrontendhandler.go @@ -15,7 +15,7 @@ func UploadFileFrontendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestUploadFileFrontend - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadfilesbackendhandler.go b/server/upload/internal/handler/uploadfilesbackendhandler.go index 870dae6e..38fe3326 100644 --- a/server/upload/internal/handler/uploadfilesbackendhandler.go +++ b/server/upload/internal/handler/uploadfilesbackendhandler.go @@ -15,7 +15,7 @@ func UploadFilesBackendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UploadFilesReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadfilesfrontendhandler.go b/server/upload/internal/handler/uploadfilesfrontendhandler.go index d8572915..f28f5eb1 100644 --- a/server/upload/internal/handler/uploadfilesfrontendhandler.go +++ b/server/upload/internal/handler/uploadfilesfrontendhandler.go @@ -15,7 +15,7 @@ func UploadFilesFrontendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UploadFilesReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadlogohandler.go b/server/upload/internal/handler/uploadlogohandler.go index b398fe37..52c58424 100644 --- a/server/upload/internal/handler/uploadlogohandler.go +++ b/server/upload/internal/handler/uploadlogohandler.go @@ -15,7 +15,7 @@ func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UploadLogoReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadqrcodehandler.go b/server/upload/internal/handler/uploadqrcodehandler.go index 816d4e30..6223728c 100644 --- a/server/upload/internal/handler/uploadqrcodehandler.go +++ b/server/upload/internal/handler/uploadqrcodehandler.go @@ -15,7 +15,7 @@ func UploadQrcodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.UploadQrcodeReq - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/upload/internal/handler/uploadupfilehandler.go b/server/upload/internal/handler/uploadupfilehandler.go index c3d54fd7..625e7d14 100644 --- a/server/upload/internal/handler/uploadupfilehandler.go +++ b/server/upload/internal/handler/uploadupfilehandler.go @@ -15,7 +15,7 @@ func UploadUpFileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestUpFile - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/webset/etc/webset.yaml b/server/webset/etc/webset.yaml index fa8374d3..e7ed61dd 100644 --- a/server/webset/etc/webset.yaml +++ b/server/webset/etc/webset.yaml @@ -1,7 +1,7 @@ Name: webset Host: localhost Port: 9913 -ReplicaId: 70 +ReplicaId: 75 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Auth: AccessSecret: fusen2023 diff --git a/server/webset/internal/handler/websetsettinghandler.go b/server/webset/internal/handler/websetsettinghandler.go index d1a56ab1..b8b0a606 100644 --- a/server/webset/internal/handler/websetsettinghandler.go +++ b/server/webset/internal/handler/websetsettinghandler.go @@ -15,7 +15,7 @@ func WebSetSettingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestWebSet - userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) if err != nil { return } diff --git a/server/webset/internal/svc/servicecontext.go b/server/webset/internal/svc/servicecontext.go index 546f6ab4..01accad9 100644 --- a/server/webset/internal/svc/servicecontext.go +++ b/server/webset/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/webset/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -25,12 +24,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, MysqlConn: conn, - SharedState: StateServer, + SharedState: nil, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/websocket/etc/websocket.yaml b/server/websocket/etc/websocket.yaml index fa9ef387..58116e52 100644 --- a/server/websocket/etc/websocket.yaml +++ b/server/websocket/etc/websocket.yaml @@ -1,7 +1,7 @@ Name: websocket Host: 0.0.0.0 Port: 9914 -ReplicaId: 75 +ReplicaId: 80 Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: diff --git a/server/websocket/internal/svc/servicecontext.go b/server/websocket/internal/svc/servicecontext.go index 31701758..0b1c7759 100644 --- a/server/websocket/internal/svc/servicecontext.go +++ b/server/websocket/internal/svc/servicecontext.go @@ -5,7 +5,6 @@ import ( "fmt" "fusenapi/server/websocket/internal/config" "fusenapi/shared" - "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -26,12 +25,12 @@ type ServiceContext struct { func NewServiceContext(c config.Config) *ServiceContext { conn := initalize.InitMysql(c.SourceMysql) - StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) + // StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ Config: c, - SharedState: StateServer, - MysqlConn: initalize.InitMysql(c.SourceMysql), + SharedState: nil, + MysqlConn: conn, AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), } diff --git a/shared/main.go b/shared/main.go index b59b1151..c4b8de3e 100644 --- a/shared/main.go +++ b/shared/main.go @@ -119,7 +119,7 @@ func StartNode(ServerID uint64, serverconfigs []*autoconfig.ConfigServer, gdb *g panic(err) } - if err := nh.StartReplica(initialMembers, false, NewFsStateMachine, rc); err != nil { + if err := nh.StartReplica(initialMembers, true, NewFsStateMachine, rc); err != nil { fmt.Fprintf(os.Stderr, "failed to add cluster, %v\n", err) os.Exit(1) } @@ -186,6 +186,7 @@ func StartNodeEx(ServerID uint64, serverconfigs []*autoconfig.ConfigServer, gdb CompactionOverhead: 5, } + datadir := filepath.Join( "shared-state", fmt.Sprintf("node%d", ServerID)) @@ -203,6 +204,7 @@ func StartNodeEx(ServerID uint64, serverconfigs []*autoconfig.ConfigServer, gdb // RaftAddress is used to identify the NodeHost instance RaftAddress: nodeAddr, } + nh, err := dragonboat.NewNodeHost(nhc) if err != nil { panic(err) diff --git a/shared/shared_state.go b/shared/shared_state.go index 46c9c446..9ce2adb1 100644 --- a/shared/shared_state.go +++ b/shared/shared_state.go @@ -2,9 +2,13 @@ package shared import ( "context" + "fusenapi/model/gmodel" + "fusenapi/utils/auth" "log" + "time" "github.com/lni/dragonboat/v4" + "gorm.io/gorm" ) type SharedState struct { @@ -13,6 +17,23 @@ type SharedState struct { nh *dragonboat.NodeHost } +func GetUserState(UserId int64, gdb *gorm.DB) (us *UserState, err error) { + models := gmodel.NewAllModels(gdb) + user, err := models.FsUser.FindUserById(context.TODO(), UserId) + if err != nil { + log.Println(err) + return nil, err + } + + userState := &UserState{ + UserId: UserId, + PwdHash: auth.StringToHash(*user.PasswordHash), + UpdateAt: time.Now(), + } + + return userState, nil +} + func (ss *SharedState) GetUserState(Userid int64) (us *UserState, err error) { ius, err := ss.nh.SyncRead(context.TODO(), ss.shardID, Userid) diff --git a/utils/basic/request_parse.go b/utils/basic/request_parse.go index 5603aa5b..a17c0142 100644 --- a/utils/basic/request_parse.go +++ b/utils/basic/request_parse.go @@ -10,6 +10,7 @@ import ( "github.com/golang-jwt/jwt" "github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/rest/httpx" + "gorm.io/gorm" ) var DefaultJwtSecret uint64 = 21321321321 @@ -51,7 +52,7 @@ func NormalAfterLogic(w http.ResponseWriter, r *http.Request, resp *Response) { } } -func RequestParse(w http.ResponseWriter, r *http.Request, state *shared.SharedState, LogicRequest any) (*auth.UserInfo, error) { +func RequestParse(w http.ResponseWriter, r *http.Request, svcCtx any, LogicRequest any) (*auth.UserInfo, error) { // log.Println(io.ReadAll(r.Body)) token, info, err := auth.ParseJwtTokenHeader[auth.UserInfo](r) //解析Token头, 和payload信息 if err != nil { @@ -63,7 +64,13 @@ func RequestParse(w http.ResponseWriter, r *http.Request, state *shared.SharedSt if info != nil { if info.IsUser() { - us, err := state.GetUserState(info.UserId) //获取缓存的用户状态 + // us, err := state.GetUserState(info.UserId) //获取缓存的用户状态 + reflect.ValueOf(svcCtx) + + ctxValue := reflect.ValueOf(svcCtx).FieldByName("MysqlConn") + gdb := ctxValue.Interface().(*gorm.DB) + + us, err := shared.GetUserState(info.UserId, gdb) if err != nil { logx.Error(err) return nil, err