|
@@ -176,9 +176,19 @@ func AddEdbClassify(classifyName string, parentId, level int, classifyType uint8
|
|
|
UniqueCode: utils.MD5(utils.DATA_PREFIX + "_" + timestamp),
|
|
|
Sort: maxSort + 1,
|
|
|
}
|
|
|
- _, err = data_manage.AddEdbClassify(classifyInfo)
|
|
|
+ newId, err := data_manage.AddEdbClassify(classifyInfo)
|
|
|
if err != nil {
|
|
|
errMsg = "保存分类失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if parentId == 0 { //一级目录的rootId等于自己本身
|
|
|
+ classifyInfo.ClassifyId = int(newId)
|
|
|
+ classifyInfo.RootId = int(newId)
|
|
|
+ err = classifyInfo.Update([]string{"RootId"})
|
|
|
+ if err != nil {
|
|
|
+ errMsg = "更新分类失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -694,7 +704,7 @@ func moveEdbClassify(parentEdbClassifyInfo, edbClassifyInfo, prevClassify, nextC
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- edbClassifyInfo.Sort = prevClassify.Sort + 1
|
|
|
+ edbClassifyInfo.Sort = prevSort + 1
|
|
|
edbClassifyInfo.ModifyTime = time.Now()
|
|
|
updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
} else if prevClassify == nil && nextClassify == nil && prevEdbInfo == nil && nextEdbInfo == nil && parentClassifyId > 0 {
|
|
@@ -801,7 +811,7 @@ func moveEdbClassify(parentEdbClassifyInfo, edbClassifyInfo, prevClassify, nextC
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- edbInfo.Sort = prevEdbInfo.Sort + 1
|
|
|
+ edbInfo.Sort = prevSort + 1
|
|
|
edbInfo.ModifyTime = time.Now()
|
|
|
updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
} else if prevClassify == nil && nextClassify == nil && prevEdbInfo == nil && nextEdbInfo == nil && parentClassifyId > 0 {
|
|
@@ -1018,22 +1028,9 @@ func GetChildClassifyByClassifyId(targetClassifyId int) (targetList []*data_mana
|
|
|
err = errors.New("获取数据失败,Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
- idMap := make(map[int]struct{})
|
|
|
if len(tmpList) > 0 {
|
|
|
for _, v := range tmpList {
|
|
|
- if v.ParentId == targetClassify.ClassifyId || v.ClassifyId == targetClassifyId {
|
|
|
- idMap[v.ClassifyId] = struct{}{}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range tmpList {
|
|
|
- if _, ok := idMap[v.ParentId]; ok {
|
|
|
- idMap[v.ClassifyId] = struct{}{}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range tmpList {
|
|
|
- if _, ok := idMap[v.ClassifyId]; ok {
|
|
|
+ if v.Level >= targetClassify.Level {
|
|
|
targetItem := new(data_manage.EdbClassifyIdItems)
|
|
|
targetItem.ClassifyId = v.ClassifyId
|
|
|
targetItem.ParentId = v.ParentId
|