From 42a965ab397a9af1d877f0ea20dc8060544b92a2 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 27 Jul 2023 16:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 5 +---- .../handler/userorderdeletehandler.go | 2 +- .../handler/orderpaymentintenthandler.go | 2 +- server/pay/internal/svc/servicecontext.go | 14 +++++++++---- .../handler/getproducttemplatetagshandler.go | 2 +- .../internal/svc/servicecontext.go | 14 +++++++++---- .../internal/handler/rendernotifyhandler.go | 2 +- .../websocket/internal/svc/servicecontext.go | 15 +++++++++----- server_api/home-user-auth.api | 20 ------------------- 9 files changed, 35 insertions(+), 41 deletions(-) diff --git a/go.mod b/go.mod index 0ff6f62a..7427c4bc 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,8 @@ require ( github.com/bwmarrin/snowflake v0.3.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/google/uuid v1.3.0 -<<<<<<< HEAD - github.com/hashicorp/raft v1.5.0 -======= github.com/gorilla/websocket v1.5.0 ->>>>>>> d843fff73d7ba5d4e14a5d86281d5166f04cb303 + github.com/hashicorp/raft v1.5.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/stripe/stripe-go/v74 v74.26.0 diff --git a/server/home-user-auth/internal/handler/userorderdeletehandler.go b/server/home-user-auth/internal/handler/userorderdeletehandler.go index 4b4ca392..c5361fc5 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, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) if err != nil { return } diff --git a/server/pay/internal/handler/orderpaymentintenthandler.go b/server/pay/internal/handler/orderpaymentintenthandler.go index d252d73c..087d4e0e 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, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) if err != nil { return } diff --git a/server/pay/internal/svc/servicecontext.go b/server/pay/internal/svc/servicecontext.go index e94ec174..5f680dfc 100644 --- a/server/pay/internal/svc/servicecontext.go +++ b/server/pay/internal/svc/servicecontext.go @@ -3,7 +3,9 @@ package svc import ( "errors" "fmt" + "fusenapi/fsm" "fusenapi/server/pay/internal/config" + "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -14,18 +16,22 @@ import ( ) type ServiceContext struct { - Config config.Config + Config config.Config + SharedState *fsm.StateCluster MysqlConn *gorm.DB AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { + conn := initalize.InitMysql(c.SourceMysql) + StateServer := fsm.StartNode(c.Name, fmt.Sprintf("%s:%d", c.Host, c.Port-2000), autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ - Config: c, - MysqlConn: initalize.InitMysql(c.SourceMysql), - AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), + Config: c, + MysqlConn: conn, + SharedState: StateServer, + 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 cf7cf96e..ab38fee3 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, &req) + userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &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 4ebf8b31..ac1ef4e6 100644 --- a/server/product-template-tag/internal/svc/servicecontext.go +++ b/server/product-template-tag/internal/svc/servicecontext.go @@ -3,7 +3,9 @@ package svc import ( "errors" "fmt" + "fusenapi/fsm" "fusenapi/server/product-template-tag/internal/config" + "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -14,18 +16,22 @@ import ( ) type ServiceContext struct { - Config config.Config + Config config.Config + SharedState *fsm.StateCluster MysqlConn *gorm.DB AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { + conn := initalize.InitMysql(c.SourceMysql) + StateServer := fsm.StartNode(c.Name, fmt.Sprintf("%s:%d", c.Host, c.Port-2000), autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ - Config: c, - MysqlConn: initalize.InitMysql(c.SourceMysql), - AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), + Config: c, + MysqlConn: conn, + SharedState: StateServer, + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } diff --git a/server/websocket/internal/handler/rendernotifyhandler.go b/server/websocket/internal/handler/rendernotifyhandler.go index ab16cdad..64aeec56 100644 --- a/server/websocket/internal/handler/rendernotifyhandler.go +++ b/server/websocket/internal/handler/rendernotifyhandler.go @@ -12,7 +12,7 @@ import ( func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RenderNotifyReq - _, err := basic.RequestParse(w, r, svcCtx, &req) + _, err := basic.RequestParse(w, r, svcCtx.SharedState, &req) if err != nil { return } diff --git a/server/websocket/internal/svc/servicecontext.go b/server/websocket/internal/svc/servicecontext.go index 9a22471e..e5c61d07 100644 --- a/server/websocket/internal/svc/servicecontext.go +++ b/server/websocket/internal/svc/servicecontext.go @@ -3,7 +3,9 @@ package svc import ( "errors" "fmt" + "fusenapi/fsm" "fusenapi/server/websocket/internal/config" + "fusenapi/utils/autoconfig" "net/http" "fusenapi/initalize" @@ -14,21 +16,24 @@ import ( ) type ServiceContext struct { - Config config.Config + Config config.Config + SharedState *fsm.StateCluster MysqlConn *gorm.DB AllModels *gmodel.AllModelsGen } func NewServiceContext(c config.Config) *ServiceContext { + conn := initalize.InitMysql(c.SourceMysql) + StateServer := fsm.StartNode(c.Name, fmt.Sprintf("%s:%d", c.Host, c.Port-2000), autoconfig.AutoGetAllServerConfig(), conn) return &ServiceContext{ - Config: c, - MysqlConn: initalize.InitMysql(c.SourceMysql), - AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), + Config: c, + MysqlConn: conn, + SharedState: StateServer, + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), } } - func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { AuthKey := r.Header.Get("Authorization") if AuthKey == "" { diff --git a/server_api/home-user-auth.api b/server_api/home-user-auth.api index 9d705ab4..a686f1f6 100644 --- a/server_api/home-user-auth.api +++ b/server_api/home-user-auth.api @@ -13,17 +13,7 @@ service home-user-auth { // @handler UserRegisterHandler // post /api/user/register(RequestUserRegister) returns (response); -<<<<<<< HEAD -======= - - @handler UserLoginHandler - post /api/user/login(RequestUserLogin) returns (response); - - @handler AcceptCookieHandler - post /api/user/accept-cookie(request) returns (response); - ->>>>>>> d843fff73d7ba5d4e14a5d86281d5166f04cb303 @handler UserFontsHandler get /api/user/fonts(request) returns (response); @@ -53,17 +43,7 @@ service home-user-auth { @handler UserOderDeleteHandler post /api/user/order-delete(RequestOrderId) returns (response); -<<<<<<< HEAD -======= - - @handler UserGoogleLoginHandler - get /api/user/oauth2/login/google(RequestGoogleLogin) returns (response); - - @handler UserEmailRegisterHandler - get /api/user/oauth2/login/register(RequestEmailRegister) returns (response); - ->>>>>>> d843fff73d7ba5d4e14a5d86281d5166f04cb303 //订单列表 @handler UserOrderListHandler get /api/user/order-list (UserOrderListReq) returns (response);