info get profile
This commit is contained in:
parent
c880cba0a3
commit
54613f5be0
|
@ -25,7 +25,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/info/user/profile/update",
|
||||
Handler: UpdateProfileHandler(serverCtx),
|
||||
Handler: UpdateProfileBaseHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
|
|
|
@ -11,22 +11,22 @@ import (
|
|||
"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) {
|
||||
|
||||
var req types.ProfileRequest
|
||||
var req types.ProfileBaseRequest
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewUpdateProfileLogic(r.Context(), svcCtx)
|
||||
l := logic.NewUpdateProfileBaseLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.UpdateProfile(&req, userinfo)
|
||||
resp := l.UpdateProfileBase(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -12,14 +12,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateProfileLogic struct {
|
||||
type UpdateProfileBaseLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProfileLogic {
|
||||
return &UpdateProfileLogic{
|
||||
func NewUpdateProfileBaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProfileBaseLogic {
|
||||
return &UpdateProfileBaseLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -27,10 +27,10 @@ func NewUpdateProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
|
|||
}
|
||||
|
||||
// 处理进入前逻辑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)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
if !userinfo.IsUser() {
|
||||
|
@ -47,6 +47,6 @@ func (l *UpdateProfileLogic) UpdateProfile(req *types.ProfileRequest, userinfo *
|
|||
}
|
||||
|
||||
// 处理逻辑后 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)
|
||||
// }
|
|
@ -36,7 +36,7 @@ type AddressRequest struct {
|
|||
State string `json:"state"` //州
|
||||
}
|
||||
|
||||
type ProfileRequest struct {
|
||||
type ProfileBaseRequest struct {
|
||||
FirstName *string `json:"first_name,optional,omitempty"` // 首名
|
||||
LastName *string `json:"last_name,optional,omitempty"` // 后名
|
||||
UserName *string `json:"user_name,optional,omitempty"` // 用户名
|
||||
|
|
|
@ -16,8 +16,8 @@ service info {
|
|||
@handler UserGetProfileHandler
|
||||
post /api/info/user/profile(QueryProfileRequest) returns (response);
|
||||
|
||||
@handler UpdateProfileHandler
|
||||
post /api/info/user/profile/update(ProfileRequest) returns (response);
|
||||
@handler UpdateProfileBaseHandler
|
||||
post /api/info/user/profile/update(ProfileBaseRequest) returns (response);
|
||||
|
||||
@handler AddressDefaultHandler
|
||||
post /api/info/address/default(AddressIdRequest) returns (response);
|
||||
|
@ -67,7 +67,7 @@ type (
|
|||
State string `json:"state"` //州
|
||||
}
|
||||
|
||||
ProfileRequest {
|
||||
ProfileBaseRequest {
|
||||
FirstName *string `json:"first_name,optional,omitempty"` // 首名
|
||||
LastName *string `json:"last_name,optional,omitempty"` // 后名
|
||||
UserName *string `json:"user_name,optional,omitempty"` // 用户名
|
||||
|
|
Loading…
Reference in New Issue
Block a user