作者 郑周

1. 优化编辑上级ID,传0或不传 取消员工的上级

... ... @@ -6,7 +6,7 @@ import (
type EditParentCommand struct {
Id int64 `cname:"用户ID" json:"id,string" valid:"Required"`
ParentId int64 `cname:"上级ID" json:"parentId,string" valid:"Required"`
ParentId int64 `cname:"上级ID" json:"parentId"`
CompanyId int `cname:"公司ID" json:"companyId"`
OperatorId int `cname:"操作人ID" json:"operatorId"`
}
... ...
... ... @@ -148,11 +148,14 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error {
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if in.ParentId != 0 {
// 上级ID是否存在
_, err = userRepo.FindOne(map[string]interface{}{"id": in.ParentId})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
user.ParentId = in.ParentId
if _, err = userRepo.Update(user); err != nil {
... ...