|
@@ -148,10 +148,13 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error { |
|
@@ -148,10 +148,13 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error { |
148
|
if err != nil {
|
148
|
if err != nil {
|
149
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
149
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
150
|
}
|
150
|
}
|
151
|
- // 上级ID是否存在
|
|
|
152
|
- _, err = userRepo.FindOne(map[string]interface{}{"id": in.ParentId})
|
|
|
153
|
- if err != nil {
|
|
|
154
|
- return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
151
|
+
|
|
|
152
|
+ if in.ParentId != 0 {
|
|
|
153
|
+ // 上级ID是否存在
|
|
|
154
|
+ _, err = userRepo.FindOne(map[string]interface{}{"id": in.ParentId})
|
|
|
155
|
+ if err != nil {
|
|
|
156
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
157
|
+ }
|
155
|
}
|
158
|
}
|
156
|
user.ParentId = in.ParentId
|
159
|
user.ParentId = in.ParentId
|
157
|
|
160
|
|