...
|
...
|
@@ -90,6 +90,9 @@ func (srv UserService) ChangePhone(resetPhoneCommand *command.ResetPhoneCommand) |
|
|
|
|
|
//UpdateUserBaseInfo 更新用户信息
|
|
|
func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateUserInfoCommand) (interface{}, error) {
|
|
|
if err := updateUserInfoCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
user, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
|
|
|
UserId: int(updateUserInfoCommand.Operator.UserId),
|
...
|
...
|
@@ -97,33 +100,33 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
|
|
|
}
|
|
|
var (
|
|
|
userName string
|
|
|
avatar string
|
|
|
)
|
|
|
if len(updateUserInfoCommand.Avatar) > 0 {
|
|
|
avatar = updateUserInfoCommand.Avatar
|
|
|
} else {
|
|
|
avatar = user.UserInfo.Avatar
|
|
|
|
|
|
if _, ok := updateUserInfoCommand.BodyKV["email"]; !ok {
|
|
|
updateUserInfoCommand.Email = user.UserInfo.Email
|
|
|
}
|
|
|
if _, ok := updateUserInfoCommand.BodyKV["phone"]; !ok {
|
|
|
updateUserInfoCommand.Phone = user.UserInfo.Phone
|
|
|
}
|
|
|
if len(updateUserInfoCommand.UserName) > 0 {
|
|
|
userName = updateUserInfoCommand.UserName
|
|
|
} else {
|
|
|
userName = user.UserInfo.UserName
|
|
|
if _, ok := updateUserInfoCommand.BodyKV["smsCode"]; ok && len(updateUserInfoCommand.SmsCode) > 0 {
|
|
|
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
|
|
|
err := smsServeGateway.CheckSmsCode(updateUserInfoCommand.Phone, updateUserInfoCommand.SmsCode)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
_, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{
|
|
|
UserId: int64(user.UserId),
|
|
|
UserName: userName,
|
|
|
Avatar: avatar,
|
|
|
Phone: user.UserInfo.Phone,
|
|
|
Email: user.UserInfo.Email,
|
|
|
UserName: updateUserInfoCommand.UserName,
|
|
|
Avatar: updateUserInfoCommand.Avatar,
|
|
|
Phone: updateUserInfoCommand.Phone,
|
|
|
Email: updateUserInfoCommand.Email,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"avatar": avatar,
|
|
|
"userName": userName,
|
|
|
"avatar": updateUserInfoCommand.Avatar,
|
|
|
"userName": updateUserInfoCommand.UserName,
|
|
|
}, nil
|
|
|
}
|
|
|
|
...
|
...
|
|