From 7c2762065c3f6c79a8ac7c5b6b319afb89589338 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 20 Jul 2023 16:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goctl_template/api/handler.tpl | 7 +++- goctl_template_backend/api/handler.tpl | 7 +++- .../handler/usergoogleloginhandler.go | 4 +-- .../internal/logic/usergoogleloginlogic.go | 2 +- server_api/home-user-auth.api | 34 +++++++++---------- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/goctl_template/api/handler.tpl b/goctl_template/api/handler.tpl index cf9cbfbc..989be2ae 100644 --- a/goctl_template/api/handler.tpl +++ b/goctl_template/api/handler.tpl @@ -2,6 +2,7 @@ package {{.PkgName}} import ( "net/http" + "reflect" "fusenapi/utils/basic" @@ -19,8 +20,12 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { // 创建一个业务逻辑层实例 {{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + {{if .HasResp}}resp{{end}} := l.{{.Call}}({{if .HasRequest}}&req, {{end}}userinfo) - basic.AfterLogic(w, r, resp) + basic.AfterLogic(w, r, resp, rl) } } diff --git a/goctl_template_backend/api/handler.tpl b/goctl_template_backend/api/handler.tpl index e6f0d377..f784b8a8 100644 --- a/goctl_template_backend/api/handler.tpl +++ b/goctl_template_backend/api/handler.tpl @@ -2,6 +2,7 @@ package {{.PkgName}} import ( "net/http" + "reflect" "fusenapi/utils/basic" @@ -18,8 +19,12 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { // 创建一个业务逻辑层实例 {{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + {{if .HasResp}}resp{{end}} := l.{{.Call}}({{if .HasRequest}}&req, {{end}}userinfo) - basic.AfterLogic(w, r, resp) + basic.AfterLogic(w, r, resp, rl) } } diff --git a/server/home-user-auth/internal/handler/usergoogleloginhandler.go b/server/home-user-auth/internal/handler/usergoogleloginhandler.go index 33c0e06d..fb1dcc4f 100644 --- a/server/home-user-auth/internal/handler/usergoogleloginhandler.go +++ b/server/home-user-auth/internal/handler/usergoogleloginhandler.go @@ -28,8 +28,6 @@ func UserGoogleLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { resp := l.UserGoogleLogin(&req, userinfo) - if !basic.AfterLogic(w, r, resp, rl) { - basic.NormalAfterLogic(w, r, resp) - } + basic.AfterLogic(w, r, resp, rl) } } diff --git a/server/home-user-auth/internal/logic/usergoogleloginlogic.go b/server/home-user-auth/internal/logic/usergoogleloginlogic.go index 12b9b56e..9e160f3f 100644 --- a/server/home-user-auth/internal/logic/usergoogleloginlogic.go +++ b/server/home-user-auth/internal/logic/usergoogleloginlogic.go @@ -41,7 +41,7 @@ func (l *UserGoogleLoginLogic) BeforeLogic(w http.ResponseWriter, r *http.Reques func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { log.Println(resp.Message) - http.Redirect(w, r, "http://localhost:9900/?token="+resp.Message, http.StatusMovedPermanently) + http.Redirect(w, r, "http://localhost:8080?token="+resp.Message, http.StatusMovedPermanently) // log.Println(r, w) } diff --git a/server_api/home-user-auth.api b/server_api/home-user-auth.api index cb4422cb..87ac55b9 100644 --- a/server_api/home-user-auth.api +++ b/server_api/home-user-auth.api @@ -10,57 +10,57 @@ info ( import "basic.api" service home-user-auth { - + // @handler UserRegisterHandler // post /api/user/register(RequestUserRegister) returns (response); - + @handler UserLoginHandler post /api/user/login(RequestUserLogin) returns (response); - + @handler AcceptCookieHandler post /api/user/accept-cookie(request) returns (response); - + @handler UserFontsHandler get /api/user/fonts(request) returns (response); - + @handler UserGetTypeHandler get /api/user/get-type(request) returns (response); - + @handler UserSaveBasicInfoHandler post /api/user/basic-info(RequestBasicInfoForm) returns (response); - + @handler UserStatusConfigHandler get /api/user/status-config(request) returns (response); - + @handler UserBasicInfoHandler get /api/user/basic-info(request) returns (response); - + @handler UserAddressListHandler get /api/user/address-list(request) returns (response); - + @handler UserAddAddressHandler post /api/user/add-address(RequestAddAddress) returns (response); - + @handler UserContactServiceHandler post /api/user/contact-service (RequestContactService) returns (response); - + // @handler UserOderListHandler // get /api/user/order-list(RequestOrderId) returns (response); - + @handler UserOderDeleteHandler post /api/user/order-delete(RequestOrderId) returns (response); - + @handler UserGoogleLoginHandler get /api/user/oauth2/login/google(RequestGoogleLogin) returns (response); - + //获取订单列表 @handler GetUserOrderListHandler get /api/user/order-list (GetUserOrderListReq) returns (response); - + //取消订单 @handler UserOrderCancelHandler get /api/user/order-cancel (UserOrderCancelReq) returns (response); - + } //取消订单