|
@@ -90,6 +90,9 @@ func (srv UserService) ChangePhone(resetPhoneCommand *command.ResetPhoneCommand) |
|
@@ -90,6 +90,9 @@ func (srv UserService) ChangePhone(resetPhoneCommand *command.ResetPhoneCommand) |
90
|
|
90
|
|
91
|
//UpdateUserBaseInfo 更新用户信息
|
91
|
//UpdateUserBaseInfo 更新用户信息
|
92
|
func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateUserInfoCommand) (interface{}, error) {
|
92
|
func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateUserInfoCommand) (interface{}, error) {
|
|
|
93
|
+ if err := updateUserInfoCommand.ValidateCommand(); err != nil {
|
|
|
94
|
+ return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
95
|
+ }
|
93
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
96
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
94
|
user, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
|
97
|
user, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{
|
95
|
UserId: int(updateUserInfoCommand.Operator.UserId),
|
98
|
UserId: int(updateUserInfoCommand.Operator.UserId),
|
|
@@ -97,33 +100,33 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU |
|
@@ -97,33 +100,33 @@ func (srv UserService) UpdateUserBaseInfo(updateUserInfoCommand *command.UpdateU |
97
|
if err != nil {
|
100
|
if err != nil {
|
98
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
|
101
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户不存在")
|
99
|
}
|
102
|
}
|
100
|
- var (
|
|
|
101
|
- userName string
|
|
|
102
|
- avatar string
|
|
|
103
|
- )
|
|
|
104
|
- if len(updateUserInfoCommand.Avatar) > 0 {
|
|
|
105
|
- avatar = updateUserInfoCommand.Avatar
|
|
|
106
|
- } else {
|
|
|
107
|
- avatar = user.UserInfo.Avatar
|
103
|
+
|
|
|
104
|
+ if _, ok := updateUserInfoCommand.BodyKV["email"]; !ok {
|
|
|
105
|
+ updateUserInfoCommand.Email = user.UserInfo.Email
|
|
|
106
|
+ }
|
|
|
107
|
+ if _, ok := updateUserInfoCommand.BodyKV["phone"]; !ok {
|
|
|
108
|
+ updateUserInfoCommand.Phone = user.UserInfo.Phone
|
108
|
}
|
109
|
}
|
109
|
- if len(updateUserInfoCommand.UserName) > 0 {
|
|
|
110
|
- userName = updateUserInfoCommand.UserName
|
|
|
111
|
- } else {
|
|
|
112
|
- userName = user.UserInfo.UserName
|
110
|
+ if _, ok := updateUserInfoCommand.BodyKV["smsCode"]; ok && len(updateUserInfoCommand.SmsCode) > 0 {
|
|
|
111
|
+ smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
|
|
|
112
|
+ err := smsServeGateway.CheckSmsCode(updateUserInfoCommand.Phone, updateUserInfoCommand.SmsCode)
|
|
|
113
|
+ if err != nil {
|
|
|
114
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
115
|
+ }
|
113
|
}
|
116
|
}
|
114
|
_, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{
|
117
|
_, err = creationUserGateway.UserUpdateBaseInfo(allied_creation_user.ReqUserUpdateBaseInfo{
|
115
|
UserId: int64(user.UserId),
|
118
|
UserId: int64(user.UserId),
|
116
|
- UserName: userName,
|
|
|
117
|
- Avatar: avatar,
|
|
|
118
|
- Phone: user.UserInfo.Phone,
|
|
|
119
|
- Email: user.UserInfo.Email,
|
119
|
+ UserName: updateUserInfoCommand.UserName,
|
|
|
120
|
+ Avatar: updateUserInfoCommand.Avatar,
|
|
|
121
|
+ Phone: updateUserInfoCommand.Phone,
|
|
|
122
|
+ Email: updateUserInfoCommand.Email,
|
120
|
})
|
123
|
})
|
121
|
if err != nil {
|
124
|
if err != nil {
|
122
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
125
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
123
|
}
|
126
|
}
|
124
|
return map[string]interface{}{
|
127
|
return map[string]interface{}{
|
125
|
- "avatar": avatar,
|
|
|
126
|
- "userName": userName,
|
128
|
+ "avatar": updateUserInfoCommand.Avatar,
|
|
|
129
|
+ "userName": updateUserInfoCommand.UserName,
|
127
|
}, nil
|
130
|
}, nil
|
128
|
}
|
131
|
}
|
129
|
|
132
|
|