作者 郑周

Merge branch 'dev-zhengzhou' into test

@@ -6,7 +6,7 @@ import ( @@ -6,7 +6,7 @@ import (
6 6
7 type EditParentCommand struct { 7 type EditParentCommand struct {
8 Id int64 `cname:"用户ID" json:"id,string" valid:"Required"` 8 Id int64 `cname:"用户ID" json:"id,string" valid:"Required"`
9 - ParentId int64 `cname:"上级ID" json:"parentId,string" valid:"Required"` 9 + ParentId int64 `cname:"上级ID" json:"parentId"`
10 CompanyId int `cname:"公司ID" json:"companyId"` 10 CompanyId int `cname:"公司ID" json:"companyId"`
11 OperatorId int `cname:"操作人ID" json:"operatorId"` 11 OperatorId int `cname:"操作人ID" json:"operatorId"`
12 } 12 }
@@ -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