45 lines
923 B
Go
45 lines
923 B
Go
package user
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/pkg/ctxdata"
|
|
"muyu-apiserver/rpc/system/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UpdateUserLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic {
|
|
return &UpdateUserLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UpdateUserLogic) UpdateUser(req *types.UpdateUserReq) (resp *types.IdResp, err error) {
|
|
id := ctxdata.GetPathId(l.ctx)
|
|
|
|
_, err = l.svcCtx.SystemRpc.UpdateUser(l.ctx, &pb.UpdateUserReq{
|
|
UserId: id,
|
|
RealName: req.RealName,
|
|
Phone: req.Phone,
|
|
Email: req.Email,
|
|
RoleId: req.RoleId,
|
|
Avatar: req.Avatar,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &types.IdResp{Id: id}, nil
|
|
}
|