|
@@ -206,6 +206,11 @@ func departmentRelationUpdate(departmentUpdate models.Department, newparent mode |
|
@@ -206,6 +206,11 @@ func departmentRelationUpdate(departmentUpdate models.Department, newparent mode |
206
|
return nil
|
206
|
return nil
|
207
|
}
|
207
|
}
|
208
|
|
208
|
|
|
|
209
|
+func setDepartmentLevel(relation string) int {
|
|
|
210
|
+ s := strings.Split(relation, ",")
|
|
|
211
|
+ return len(s) - 3
|
|
|
212
|
+}
|
|
|
213
|
+
|
209
|
//AddDepartmentData ...
|
214
|
//AddDepartmentData ...
|
210
|
func AddDepartmentData(data []ModuleDeparmentData) error {
|
215
|
func AddDepartmentData(data []ModuleDeparmentData) error {
|
211
|
if len(data) == 0 {
|
216
|
if len(data) == 0 {
|
|
@@ -238,6 +243,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
@@ -238,6 +243,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
238
|
BusinessDepartmentId: v.Id,
|
243
|
BusinessDepartmentId: v.Id,
|
239
|
DeleteAt: time.Unix(0, 0),
|
244
|
DeleteAt: time.Unix(0, 0),
|
240
|
CreateAt: time.Now(),
|
245
|
CreateAt: time.Now(),
|
|
|
246
|
+ Level: v.Level,
|
241
|
}
|
247
|
}
|
242
|
if v.ParentId > 0 {
|
248
|
if v.ParentId > 0 {
|
243
|
parentDepart := &models.Department{}
|
249
|
parentDepart := &models.Department{}
|
|
@@ -257,7 +263,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
@@ -257,7 +263,7 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
257
|
departmentData.SetRelation(topDepartment)
|
263
|
departmentData.SetRelation(topDepartment)
|
258
|
}
|
264
|
}
|
259
|
|
265
|
|
260
|
- departmentData.Level = setDepartmentLevel(departmentData.Relation)
|
266
|
+ // departmentData.Level = setDepartmentLevel(departmentData.Relation)
|
261
|
_, err = models.AddDepartment(departmentData, o)
|
267
|
_, err = models.AddDepartment(departmentData, o)
|
262
|
if err != nil {
|
268
|
if err != nil {
|
263
|
e := fmt.Errorf("存储部门数据失败,err:%s", err)
|
269
|
e := fmt.Errorf("存储部门数据失败,err:%s", err)
|
|
@@ -270,11 +276,6 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
|
@@ -270,11 +276,6 @@ func AddDepartmentData(data []ModuleDeparmentData) error { |
270
|
return nil
|
276
|
return nil
|
271
|
}
|
277
|
}
|
272
|
|
278
|
|
273
|
-func setDepartmentLevel(relation string) int {
|
|
|
274
|
- s := strings.Split(relation, ",")
|
|
|
275
|
- return len(s) - 3
|
|
|
276
|
-}
|
|
|
277
|
-
|
|
|
278
|
//DeleteDepartmentData ...
|
279
|
//DeleteDepartmentData ...
|
279
|
func DeleteDepartmentData(ids []int64) error {
|
280
|
func DeleteDepartmentData(ids []int64) error {
|
280
|
o := orm.NewOrm()
|
281
|
o := orm.NewOrm()
|