...
|
...
|
@@ -28,6 +28,11 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI |
|
|
DeleteAt: time.Unix(0, 0),
|
|
|
ParentId: param.ParentID,
|
|
|
}
|
|
|
ok := models.ExistPositiontName(param.ParentID, param.Name)
|
|
|
if ok {
|
|
|
return nil, protocol.NewErrWithMessage("10013")
|
|
|
}
|
|
|
//检查上级
|
|
|
if param.ParentID > 0 {
|
|
|
parentPosition, err = models.GetPositionById(param.ParentID)
|
|
|
if err != nil {
|
...
|
...
|
@@ -40,6 +45,11 @@ func PositionAdd(param protocol.RequestPositionAdd) (*protocol.ResponsePositionI |
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
r := parentPosition.Relation
|
|
|
rs := strings.Split(r, "/")
|
|
|
if len(rs) >= 10 { //层级不能超过10级
|
|
|
return nil, protocol.NewErrWithMessage("10012")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
o := orm.NewOrm()
|
...
|
...
|
@@ -117,17 +127,23 @@ func PositionEdit(param protocol.RequestPositionEdit) (*protocol.ResponsePositio |
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
r := parentPosition.Relation
|
|
|
rs := strings.Split(r, "/")
|
|
|
if len(rs) >= 10 { //层级不能超过10级
|
|
|
return nil, protocol.NewErrWithMessage("10012")
|
|
|
}
|
|
|
}
|
|
|
//更新部门关系数据
|
|
|
if positionUpdate.ParentId != param.ParentID {
|
|
|
err = positionRelationUpdate(positionUpdate, parentPosition)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("positionRelationUpdate err:%s", err)
|
|
|
log.Error(e.Error())
|
|
|
return nil, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
}
|
|
|
positioninfo = &protocol.ResponsePositionInfo{
|
|
|
Id: positionUpdate.Id,
|
|
|
|
|
|
Name: positionUpdate.Name,
|
|
|
}
|
|
|
if param.ParentID != 0 {
|
...
|
...
|
|