Merge branch 'develop' into orders

This commit is contained in:
Hiven
2023-07-24 19:15:33 +08:00
98 changed files with 490 additions and 145 deletions

View File

@@ -28,7 +28,7 @@ func AcceptCookieHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.AcceptCookie(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserAddAddressHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserAddAddress(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserAddressListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserAddressList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserBasicInfo(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserContactServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserContactService(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserEmailRegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserEmailRegister(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserFontsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserFonts(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserGetTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserGetType(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserGoogleLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserGoogleLogin(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserLogin(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserOderDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserOderDelete(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserOrderCancelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserOrderCancel(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserOrderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserOrderList(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserSaveBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserSaveBasicInfo(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -28,7 +28,7 @@ func UserStatusConfigHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
resp := l.UserStatusConfig(&req, userinfo)
if !basic.AfterLogic(w, r, rl) {
if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp)
}
}

View File

@@ -31,7 +31,7 @@ func NewUserEmailRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext)
// }
// 处理逻辑后 w,r 如:重定向
// func (l *UserEmailRegisterLogic) AfterLogic(w http.ResponseWriter, r *http.Request) {
// func (l *UserEmailRegisterLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// }
func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegister, userinfo *auth.UserInfo) (resp *basic.Response) {

View File

@@ -45,7 +45,7 @@ func NewUserGoogleLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U
// log.Println(r, w)
// }
func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request) {
func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
rurl := fmt.Sprintf(
l.svcCtx.Config.MainAddress+"/oauth?token=%s&is_registered=%t&register_token=%s",

View File

@@ -23,7 +23,6 @@ type UserLoginLogic struct {
svcCtx *svc.ServiceContext
token string
resp *basic.Response
}
func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLoginLogic {
@@ -34,12 +33,12 @@ func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLog
}
}
func (l *UserLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request) {
func (l *UserLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
if l.token != "" {
w.Header().Add("Authorization", fmt.Sprintf("Bearer %s", l.token))
}
httpx.OkJsonCtx(r.Context(), w, l.resp)
httpx.OkJsonCtx(r.Context(), w, resp)
}
func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin, userinfo *auth.UserInfo) (resp *basic.Response) {
@@ -79,7 +78,6 @@ func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin, userinfo *auth.U
}
l.token = jwtToken
l.resp = resp.SetStatus(basic.CodeOK, data)
// 返回认证成功的状态码以及数据对象 data 和 JWT Token。
return resp.SetStatus(basic.CodeOK, data)