package logic import ( "context" sysModel "sundynix-micro-go/app/system/model" "sundynix-micro-go/app/system/rpc/internal/svc" "sundynix-micro-go/app/system/rpc/system" "github.com/zeromicro/go-zero/core/logx" ) type UpdateUserLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic { return &UpdateUserLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)} } func (l *UpdateUserLogic) UpdateUser(in *system.UpdateUserReq) (*system.CommonResp, error) { updates := map[string]interface{}{} if in.Name != "" { updates["name"] = in.Name } if in.Account != "" { updates["account"] = in.Account } if in.Phone != "" { updates["phone"] = in.Phone } if in.AvatarId != "" { updates["avatar_id"] = in.AvatarId } if in.NickName != "" { updates["nick_name"] = in.NickName } if err := l.svcCtx.DB.Model(&sysModel.SundynixUser{}).Where("id = ?", in.Id).Updates(updates).Error; err != nil { return nil, err } return &system.CommonResp{Code: 200, Msg: "success"}, nil }