...
|
...
|
@@ -206,6 +206,11 @@ func departmentRelationUpdate(departmentUpdate models.Department, newparent mode |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func setDepartmentLevel(relation string) int {
|
|
|
s := strings.Split(relation, ",")
|
|
|
return len(s) - 3
|
|
|
}
|
|
|
|
|
|
//AddDepartmentData ...
|
|
|
func AddDepartmentData(data []ModuleDeparmentData) error {
|
|
|
if len(data) == 0 {
|
...
|
...
|
@@ -238,6 +243,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
|
BusinessDepartmentId: v.Id,
|
|
|
DeleteAt: time.Unix(0, 0),
|
|
|
CreateAt: time.Now(),
|
|
|
Level: v.Level,
|
|
|
}
|
|
|
if v.ParentId > 0 {
|
|
|
parentDepart := &models.Department{}
|
...
|
...
|
@@ -257,7 +263,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
|
departmentData.SetRelation(topDepartment)
|
|
|
}
|
|
|
|
|
|
departmentData.Level = setDepartmentLevel(departmentData.Relation)
|
|
|
// departmentData.Level = setDepartmentLevel(departmentData.Relation)
|
|
|
_, err = models.AddDepartment(departmentData, o)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("存储部门数据失败,err:%s", err)
|
...
|
...
|
@@ -270,11 +276,6 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func setDepartmentLevel(relation string) int {
|
|
|
s := strings.Split(relation, ",")
|
|
|
return len(s) - 3
|
|
|
}
|
|
|
|
|
|
//DeleteDepartmentData ...
|
|
|
func DeleteDepartmentData(ids []int64) error {
|
|
|
o := orm.NewOrm()
|
...
|
...
|
|