|
@@ -567,120 +567,7 @@ func Delete(classifyId, edbInfoId int, sysUser *system.Admin, requestBody, reque
|
|
|
}
|
|
|
|
|
|
|
|
|
-func MoveEdbClassify(classifyId, parentClassifyId, prevClassifyId, nextClassifyId int, sysUser *system.Admin) (err error, errMsg string) {
|
|
|
-
|
|
|
- edbClassifyInfo, err := data_manage.GetEdbClassifyById(classifyId)
|
|
|
- if err != nil {
|
|
|
- errMsg = "移动失败"
|
|
|
- err = errors.New("获取分类信息失败,Err:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- {
|
|
|
- if edbClassifyInfo.ClassifyType == 0 {
|
|
|
- button := GetEdbClassifyOpButton(sysUser, edbClassifyInfo.SysUserId)
|
|
|
- if !button.MoveButton {
|
|
|
- errMsg = "无操作权限"
|
|
|
- err = errors.New(errMsg)
|
|
|
- return
|
|
|
- }
|
|
|
- } else if edbClassifyInfo.ClassifyType == 1 {
|
|
|
- button := GetPredictEdbClassifyOpButton(sysUser, edbClassifyInfo.SysUserId)
|
|
|
- if !button.MoveButton {
|
|
|
- errMsg = "无操作权限"
|
|
|
- err = errors.New(errMsg)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- updateCol := make([]string, 0)
|
|
|
-
|
|
|
-
|
|
|
- if edbClassifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
|
|
|
- parentEdbClassifyInfo, tmpErr := data_manage.GetEdbClassifyById(parentClassifyId)
|
|
|
- if tmpErr != nil {
|
|
|
- errMsg = "移动失败"
|
|
|
- err = errors.New("获取上级分类信息失败,Err:" + tmpErr.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- edbClassifyInfo.ParentId = parentEdbClassifyInfo.ClassifyId
|
|
|
- edbClassifyInfo.Level = parentEdbClassifyInfo.Level + 1
|
|
|
- edbClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if prevClassifyId > 0 {
|
|
|
- prevClassify, tmpErr := data_manage.GetEdbClassifyById(prevClassifyId)
|
|
|
- if tmpErr != nil {
|
|
|
- errMsg = "移动失败"
|
|
|
- err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + tmpErr.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if nextClassifyId > 0 {
|
|
|
-
|
|
|
- nextClassify, tmpErr := data_manage.GetEdbClassifyById(nextClassifyId)
|
|
|
- if tmpErr != nil {
|
|
|
- errMsg = "移动失败"
|
|
|
- err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + tmpErr.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == edbClassifyInfo.Sort {
|
|
|
-
|
|
|
- updateSortStr := `sort + 2`
|
|
|
- _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, prevClassify.ClassifyId, prevClassify.Sort, updateSortStr, edbClassifyInfo.ClassifyType)
|
|
|
- } else {
|
|
|
-
|
|
|
- if nextClassify.Sort-prevClassify.Sort == 1 {
|
|
|
-
|
|
|
- updateSortStr := `sort + 1`
|
|
|
- _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr, edbClassifyInfo.ClassifyType)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- edbClassifyInfo.Sort = prevClassify.Sort + 1
|
|
|
- edbClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
- } else {
|
|
|
- firstClassify, tmpErr := data_manage.GetFirstEdbClassifyByParentId(edbClassifyInfo.ParentId)
|
|
|
- if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
|
|
|
- errMsg = "移动失败"
|
|
|
- err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if firstClassify != nil && firstClassify.Sort == 0 {
|
|
|
- updateSortStr := ` sort + 1 `
|
|
|
- _ = data_manage.UpdateEdbClassifySortByParentId(firstClassify.ParentId, firstClassify.ClassifyId-1, 0, updateSortStr, edbClassifyInfo.ClassifyType)
|
|
|
- }
|
|
|
-
|
|
|
- edbClassifyInfo.Sort = 0
|
|
|
- edbClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if len(updateCol) > 0 {
|
|
|
- err = edbClassifyInfo.Update(updateCol)
|
|
|
- if err != nil {
|
|
|
- errMsg = "移动失败"
|
|
|
- err = errors.New("修改失败,Err:" + err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-func MoveEdbClassifyV2(req data_manage.MoveEdbClassifyReq, sysUser *system.Admin, classifyType uint8) (err error, errMsg string) {
|
|
|
+func MoveEdbClassify(req data_manage.MoveEdbClassifyReq, sysUser *system.Admin, classifyType uint8) (err error, errMsg string) {
|
|
|
|
|
|
classifyId := req.ClassifyId
|
|
|
parentClassifyId := req.ParentClassifyId
|
|
@@ -813,21 +700,22 @@ func MoveEdbClassifyV2(req data_manage.MoveEdbClassifyReq, sysUser *system.Admin
|
|
|
nextSort = nextEdbInfo.Sort
|
|
|
}
|
|
|
|
|
|
- err, errMsg = moveEdbClassifyV2(parentEdbClassifyInfo, edbClassifyInfo, prevClassify, edbInfo, prevEdbInfo, parentClassifyId, prevSort, nextSort, classifyType)
|
|
|
+ err, errMsg = moveEdbClassify(parentEdbClassifyInfo, edbClassifyInfo, prevClassify, edbInfo, prevEdbInfo, parentClassifyId, prevSort, nextSort, classifyType)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-func moveEdbClassifyV2(parentEdbClassifyInfo, edbClassifyInfo, prevClassify *data_manage.EdbClassify, edbInfo, prevEdbInfo *data_manage.EdbInfo, parentClassifyId int, prevSort, nextSort int, classifyType uint8) (err error, errMsg string) {
|
|
|
+
|
|
|
+func moveEdbClassify(parentEdbClassifyInfo, edbClassifyInfo, prevClassify *data_manage.EdbClassify, edbInfo, prevEdbInfo *data_manage.EdbInfo, parentClassifyId int, prevSort, nextSort int, classifyType uint8) (err error, errMsg string) {
|
|
|
updateCol := make([]string, 0)
|
|
|
|
|
|
if edbClassifyInfo != nil {
|
|
|
|
|
|
if edbClassifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 {
|
|
|
edbClassifyInfo.ParentId = parentEdbClassifyInfo.ClassifyId
|
|
|
+ edbClassifyInfo.RootId = parentEdbClassifyInfo.RootId
|
|
|
edbClassifyInfo.Level = parentEdbClassifyInfo.Level + 1
|
|
|
edbClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
|
|
|
+ updateCol = append(updateCol, "ParentId", "RootId", "Level", "ModifyTime")
|
|
|
}
|
|
|
|
|
|
if prevSort > 0 {
|