Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-09-26 18:21:13 +08:00
commit fcfea291e5
5 changed files with 16 additions and 16 deletions

View File

@ -24,8 +24,8 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
}, },
{ {
Method: http.MethodPost, Method: http.MethodPost,
Path: "/api/info/user/profile/update", Path: "/api/info/user/profile/base/update",
Handler: UpdateProfileHandler(serverCtx), Handler: UpdateProfileBaseHandler(serverCtx),
}, },
{ {
Method: http.MethodPost, Method: http.MethodPost,

View File

@ -11,22 +11,22 @@ import (
"fusenapi/server/info/internal/types" "fusenapi/server/info/internal/types"
) )
func UpdateProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { func UpdateProfileBaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
var req types.ProfileRequest var req types.ProfileBaseRequest
userinfo, err := basic.RequestParse(w, r, svcCtx, &req) userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil { if err != nil {
return return
} }
// 创建一个业务逻辑层实例 // 创建一个业务逻辑层实例
l := logic.NewUpdateProfileLogic(r.Context(), svcCtx) l := logic.NewUpdateProfileBaseLogic(r.Context(), svcCtx)
rl := reflect.ValueOf(l) rl := reflect.ValueOf(l)
basic.BeforeLogic(w, r, rl) basic.BeforeLogic(w, r, rl)
resp := l.UpdateProfile(&req, userinfo) resp := l.UpdateProfileBase(&req, userinfo)
if !basic.AfterLogic(w, r, rl, resp) { if !basic.AfterLogic(w, r, rl, resp) {
basic.NormalAfterLogic(w, r, resp) basic.NormalAfterLogic(w, r, resp)

View File

@ -12,14 +12,14 @@ import (
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
) )
type UpdateProfileLogic struct { type UpdateProfileBaseLogic struct {
logx.Logger logx.Logger
ctx context.Context ctx context.Context
svcCtx *svc.ServiceContext svcCtx *svc.ServiceContext
} }
func NewUpdateProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProfileLogic { func NewUpdateProfileBaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProfileBaseLogic {
return &UpdateProfileLogic{ return &UpdateProfileBaseLogic{
Logger: logx.WithContext(ctx), Logger: logx.WithContext(ctx),
ctx: ctx, ctx: ctx,
svcCtx: svcCtx, svcCtx: svcCtx,
@ -27,10 +27,10 @@ func NewUpdateProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
} }
// 处理进入前逻辑w,r // 处理进入前逻辑w,r
// func (l *UpdateProfileLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { // func (l *UpdateProfileBaseLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// } // }
func (l *UpdateProfileLogic) UpdateProfile(req *types.ProfileRequest, userinfo *auth.UserInfo) (resp *basic.Response) { func (l *UpdateProfileBaseLogic) UpdateProfileBase(req *types.ProfileBaseRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null // userinfo 传入值时, 一定不为null
if !userinfo.IsUser() { if !userinfo.IsUser() {
@ -47,6 +47,6 @@ func (l *UpdateProfileLogic) UpdateProfile(req *types.ProfileRequest, userinfo *
} }
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 // 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *UpdateProfileLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { // func (l *UpdateProfileBaseLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp) // // httpx.OkJsonCtx(r.Context(), w, resp)
// } // }

View File

@ -36,7 +36,7 @@ type AddressRequest struct {
State string `json:"state"` //州 State string `json:"state"` //州
} }
type ProfileRequest struct { type ProfileBaseRequest struct {
FirstName *string `json:"first_name,optional,omitempty"` // 首名 FirstName *string `json:"first_name,optional,omitempty"` // 首名
LastName *string `json:"last_name,optional,omitempty"` // 后名 LastName *string `json:"last_name,optional,omitempty"` // 后名
UserName *string `json:"user_name,optional,omitempty"` // 用户名 UserName *string `json:"user_name,optional,omitempty"` // 用户名

View File

@ -16,8 +16,8 @@ service info {
@handler UserGetProfileHandler @handler UserGetProfileHandler
post /api/info/user/profile(QueryProfileRequest) returns (response); post /api/info/user/profile(QueryProfileRequest) returns (response);
@handler UpdateProfileHandler @handler UpdateProfileBaseHandler
post /api/info/user/profile/update(ProfileRequest) returns (response); post /api/info/user/profile/base/update(ProfileBaseRequest) returns (response);
@handler AddressDefaultHandler @handler AddressDefaultHandler
post /api/info/address/default(AddressIdRequest) returns (response); post /api/info/address/default(AddressIdRequest) returns (response);
@ -67,7 +67,7 @@ type (
State string `json:"state"` //州 State string `json:"state"` //州
} }
ProfileRequest { ProfileBaseRequest {
FirstName *string `json:"first_name,optional,omitempty"` // 首名 FirstName *string `json:"first_name,optional,omitempty"` // 首名
LastName *string `json:"last_name,optional,omitempty"` // 后名 LastName *string `json:"last_name,optional,omitempty"` // 后名
UserName *string `json:"user_name,optional,omitempty"` // 用户名 UserName *string `json:"user_name,optional,omitempty"` // 用户名