|
@@ -1225,92 +1225,403 @@ func (this *SandboxController) ChartClassifyMove() {
|
|
|
|
|
|
updateCol := make([]string, 0)
|
|
|
|
|
|
-
|
|
|
- if sandboxClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
|
|
|
- parentChartClassifyInfo, err := sandbox.GetSandboxClassifyById(req.ParentClassifyId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取上级分类信息失败,Err:" + err.Error()
|
|
|
+
|
|
|
+ if req.SandboxId > 0 {
|
|
|
+
|
|
|
+ count, _ := sandbox.GetSandboxClassifyCountById(req.ClassifyId)
|
|
|
+ if count <= 0 {
|
|
|
+ br.Msg = "分类已被删除,不可移动,请刷新页面"
|
|
|
return
|
|
|
}
|
|
|
- sandboxClassifyInfo.ParentId = parentChartClassifyInfo.SandboxClassifyId
|
|
|
- sandboxClassifyInfo.Level = parentChartClassifyInfo.Level + 1
|
|
|
- sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
|
|
|
- } else if sandboxClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId == 0 {
|
|
|
-
|
|
|
- sandboxClassifyInfo.ParentId = req.ParentClassifyId
|
|
|
- sandboxClassifyInfo.Level = 1
|
|
|
- sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if req.PrevClassifyId > 0 {
|
|
|
-
|
|
|
- prevClassify, err := sandbox.GetSandboxClassifyById(req.PrevClassifyId)
|
|
|
+
|
|
|
+ sandboxInfo, err := sandbox.GetSandboxById(req.SandboxId)
|
|
|
if err != nil {
|
|
|
br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "获取沙盘信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if req.NextClassifyId > 0 {
|
|
|
-
|
|
|
- nextClassify, err := sandbox.GetSandboxClassifyById(req.NextClassifyId)
|
|
|
+
|
|
|
+ if sandboxInfo.SandboxClassifyId != req.ParentClassifyId {
|
|
|
+
|
|
|
+ tmpSandboxInfo, tmpErr := sandbox.GetSandboxByClassifyIdAndName(req.ParentClassifyId, sandboxInfo.Name)
|
|
|
+ if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if tmpSandboxInfo != nil {
|
|
|
+ br.Msg = "移动失败,同一个分类下沙盘名称不允许重复"
|
|
|
+ br.ErrMsg = "移动失败,同一个分类下沙盘名称不允许重复"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = sandbox.MoveSandbox(req.SandboxId, req.ParentClassifyId)
|
|
|
if err != nil {
|
|
|
br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ br.ErrMsg = "移动失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == sandboxClassifyInfo.Sort {
|
|
|
-
|
|
|
- updateSortStr := `sort + 2`
|
|
|
- _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, prevClassify.SandboxClassifyId, prevClassify.Sort, updateSortStr)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ updateCol := make([]string, 0)
|
|
|
+
|
|
|
+ if req.PrevId > 0 {
|
|
|
+ if req.PrevType == 1 {
|
|
|
+
|
|
|
+ prevClassify, err := sandbox.GetSandboxClassifyById(req.PrevId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if req.NextId > 0 {
|
|
|
+ if req.NextType == 1 {
|
|
|
+
|
|
|
+
|
|
|
+ nextClassify, err := sandbox.GetSandboxClassifyById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == sandboxClassifyInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, prevClassify.SandboxClassifyId, prevClassify.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextClassify.Sort-prevClassify.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ nextChartInfo, err := sandbox.GetSandboxById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevClassify.Sort == nextChartInfo.Sort || prevClassify.Sort == sandboxInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, prevClassify.SandboxClassifyId, prevClassify.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextChartInfo.Sort-prevClassify.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.SandboxClassifyId, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sandboxInfo.Sort = prevClassify.Sort + 1
|
|
|
+ sandboxInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
+
|
|
|
} else {
|
|
|
-
|
|
|
- if nextClassify.Sort-prevClassify.Sort == 1 {
|
|
|
-
|
|
|
- updateSortStr := `sort + 1`
|
|
|
- _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
|
|
|
+ prevSandbox, err := sandbox.GetSandboxById(req.PrevId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ if req.NextId > 0 {
|
|
|
+ if req.NextType == 1 {
|
|
|
+
|
|
|
+
|
|
|
+ nextClassify, err := sandbox.GetSandboxClassifyById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevSandbox.Sort == nextClassify.Sort || prevSandbox.Sort == sandboxClassifyInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextClassify.Sort-prevSandbox.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ nextChartInfo, err := sandbox.GetSandboxById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevSandbox.Sort == nextChartInfo.Sort || prevSandbox.Sort == sandboxInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextChartInfo.Sort-prevSandbox.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sandboxInfo.Sort = prevSandbox.Sort + 1
|
|
|
+ sandboxInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- sandboxClassifyInfo.Sort = prevClassify.Sort + 1
|
|
|
- sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
|
|
|
- } else {
|
|
|
- firstClassify, err := sandbox.GetFirstSandboxClassifyByParentId(sandboxClassifyInfo.ParentId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+ } else {
|
|
|
+
|
|
|
+ firstClassify, err := sandbox.GetFirstSandboxByClassifyId(req.ClassifyId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if firstClassify != nil && firstClassify.Sort == 0 {
|
|
|
+ updateSortStr := ` sort + 1 `
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(firstClassify.SandboxClassifyId, 0, firstClassify.SandboxId-1, updateSortStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ sandboxInfo.Sort = 0
|
|
|
+ sandboxInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if firstClassify != nil && firstClassify.Sort == 0 {
|
|
|
- updateSortStr := ` sort + 1 `
|
|
|
- _ = sandbox.UpdateSandboxClassifySortByParentId(firstClassify.ParentId, firstClassify.SandboxClassifyId-1, 0, updateSortStr)
|
|
|
+
|
|
|
+ if len(updateCol) > 0 {
|
|
|
+ err = sandboxInfo.Update(updateCol)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "修改失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ if sandboxClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
|
|
|
+ parentChartClassifyInfo, err := sandbox.GetSandboxClassifyById(req.ParentClassifyId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取上级分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sandboxClassifyInfo.ParentId = parentChartClassifyInfo.SandboxClassifyId
|
|
|
+ sandboxClassifyInfo.Level = parentChartClassifyInfo.Level + 1
|
|
|
+ sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
|
|
|
+ } else if sandboxClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId == 0 {
|
|
|
+
|
|
|
+ sandboxClassifyInfo.ParentId = req.ParentClassifyId
|
|
|
+ sandboxClassifyInfo.Level = 1
|
|
|
+ sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
|
|
|
}
|
|
|
|
|
|
- sandboxClassifyInfo.Sort = 0
|
|
|
- sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
- }
|
|
|
+
|
|
|
+ if req.PrevId > 0 {
|
|
|
+ if req.PrevType == 1 {
|
|
|
+
|
|
|
+
|
|
|
+ prevClassify, err := sandbox.GetSandboxClassifyById(req.PrevId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- if len(updateCol) > 0 {
|
|
|
- err = sandboxClassifyInfo.Update(updateCol)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "修改失败,Err:" + err.Error()
|
|
|
- return
|
|
|
+
|
|
|
+ if req.NextId > 0 {
|
|
|
+ if req.NextType == 1 {
|
|
|
+
|
|
|
+
|
|
|
+ nextClassify, err := sandbox.GetSandboxClassifyById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == sandboxClassifyInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, prevClassify.SandboxClassifyId, prevClassify.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextClassify.Sort-prevClassify.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ nextChartInfo, err := sandbox.GetSandboxById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevClassify.Sort == nextChartInfo.Sort || prevClassify.Sort == sandboxClassifyInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, prevClassify.SandboxClassifyId, prevClassify.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextChartInfo.Sort-prevClassify.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.SandboxClassifyId, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevClassify.SandboxClassifyId, prevClassify.Sort, 0, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sandboxClassifyInfo.Sort = prevClassify.Sort + 1
|
|
|
+ sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ prevSandbox, err := sandbox.GetSandboxById(req.PrevId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if req.NextId > 0 {
|
|
|
+ if req.NextType == 1 {
|
|
|
+
|
|
|
+
|
|
|
+ nextClassify, err := sandbox.GetSandboxClassifyById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevSandbox.Sort == nextClassify.Sort || prevSandbox.Sort == sandboxClassifyInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextClassify.Sort-prevSandbox.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ nextChartInfo, err := sandbox.GetSandboxById(req.NextId)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if prevSandbox.Sort == nextChartInfo.Sort || prevSandbox.Sort == sandboxClassifyInfo.Sort {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 2`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if nextChartInfo.Sort-prevSandbox.Sort == 1 {
|
|
|
+
|
|
|
+ updateSortStr := `sort + 1`
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(prevSandbox.SandboxClassifyId, 0, prevSandbox.Sort, updateSortStr)
|
|
|
+ _ = sandbox.UpdateSandboxSortByClassifyId(prevSandbox.SandboxClassifyId, prevSandbox.Sort, prevSandbox.SandboxId, updateSortStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ sandboxClassifyInfo.Sort = prevSandbox.Sort + 1
|
|
|
+ sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ firstClassify, err := sandbox.GetFirstSandboxClassifyByParentId(sandboxClassifyInfo.ParentId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if firstClassify != nil && firstClassify.Sort == 0 {
|
|
|
+ updateSortStr := ` sort + 1 `
|
|
|
+ _ = sandbox.UpdateSandboxClassifySortByParentId(firstClassify.ParentId, firstClassify.SandboxClassifyId-1, 0, updateSortStr)
|
|
|
+ }
|
|
|
+
|
|
|
+ sandboxClassifyInfo.Sort = 0
|
|
|
+ sandboxClassifyInfo.ModifyTime = time.Now()
|
|
|
+ updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if len(updateCol) > 0 {
|
|
|
+ err = sandboxClassifyInfo.Update(updateCol)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "移动失败"
|
|
|
+ br.ErrMsg = "修改失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "移动成功"
|
|
@@ -1581,159 +1892,6 @@ func (this *SandboxController) GetSandboxDetail() {
|
|
|
br.Data = sandboxVersionInfo
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (this *SandboxController) SandboxMove() {
|
|
|
- br := new(models.BaseResponse).Init()
|
|
|
- defer func() {
|
|
|
- this.Data["json"] = br
|
|
|
- this.ServeJSON()
|
|
|
- }()
|
|
|
-
|
|
|
- sysUser := this.SysUser
|
|
|
- if sysUser == nil {
|
|
|
- br.Msg = "请登录"
|
|
|
- br.ErrMsg = "请登录,SysUser Is Empty"
|
|
|
- br.Ret = 408
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- var req sandbox.MoveSandboxReq
|
|
|
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "参数解析异常!"
|
|
|
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if req.SandboxId <= 0 {
|
|
|
- br.Msg = "参数错误"
|
|
|
- br.ErrMsg = "沙盘id小于等于0"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if req.SandboxClassifyId <= 0 {
|
|
|
- br.Msg = "请选择分类"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- count, _ := sandbox.GetSandboxClassifyCountById(req.SandboxClassifyId)
|
|
|
- if count <= 0 {
|
|
|
- br.Msg = "分类已被删除,不可移动,请刷新页面"
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- sandboxInfo, err := sandbox.GetSandboxById(req.SandboxId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取沙盘信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if sandboxInfo.SandboxClassifyId != req.SandboxClassifyId {
|
|
|
-
|
|
|
- tmpSandboxInfo, tmpErr := sandbox.GetSandboxByClassifyIdAndName(req.SandboxClassifyId, sandboxInfo.Name)
|
|
|
- if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- if tmpSandboxInfo != nil {
|
|
|
- br.Msg = "移动失败,同一个分类下沙盘名称不允许重复"
|
|
|
- br.ErrMsg = "移动失败,同一个分类下沙盘名称不允许重复"
|
|
|
- return
|
|
|
- }
|
|
|
- err = sandbox.MoveSandbox(req.SandboxId, req.SandboxClassifyId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "移动失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- updateCol := make([]string, 0)
|
|
|
-
|
|
|
- if req.PrevSandboxId > 0 {
|
|
|
- prevChartInfo, err := sandbox.GetSandboxById(req.PrevSandboxId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if req.NextSandboxId > 0 {
|
|
|
-
|
|
|
- nextChartInfo, err := sandbox.GetSandboxById(req.NextSandboxId)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if prevChartInfo.Sort == nextChartInfo.Sort || prevChartInfo.Sort == sandboxInfo.Sort {
|
|
|
-
|
|
|
- updateSortStr := `sort + 2`
|
|
|
- _ = sandbox.UpdateSandboxSortByClassifyId(prevChartInfo.SandboxClassifyId, prevChartInfo.Sort, prevChartInfo.SandboxId, updateSortStr)
|
|
|
- } else {
|
|
|
-
|
|
|
- if nextChartInfo.Sort-prevChartInfo.Sort == 1 {
|
|
|
-
|
|
|
- updateSortStr := `sort + 1`
|
|
|
- _ = sandbox.UpdateSandboxSortByClassifyId(prevChartInfo.SandboxClassifyId, prevChartInfo.Sort, prevChartInfo.SandboxId, updateSortStr)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- sandboxInfo.Sort = prevChartInfo.Sort + 1
|
|
|
- sandboxInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
-
|
|
|
- } else {
|
|
|
- firstClassify, err := sandbox.GetFirstSandboxByClassifyId(req.SandboxClassifyId)
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if firstClassify != nil && firstClassify.Sort == 0 {
|
|
|
- updateSortStr := ` sort + 1 `
|
|
|
- _ = sandbox.UpdateSandboxSortByClassifyId(firstClassify.SandboxClassifyId, 0, firstClassify.SandboxId-1, updateSortStr)
|
|
|
- }
|
|
|
-
|
|
|
- sandboxInfo.Sort = 0
|
|
|
- sandboxInfo.ModifyTime = time.Now()
|
|
|
- updateCol = append(updateCol, "Sort", "ModifyTime")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if len(updateCol) > 0 {
|
|
|
- err = sandboxInfo.Update(updateCol)
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "修改失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if err != nil {
|
|
|
- br.Msg = "移动失败"
|
|
|
- br.ErrMsg = "修改失败,Err:" + err.Error()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- br.Ret = 200
|
|
|
- br.Success = true
|
|
|
- br.Msg = "移动成功"
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -1818,4 +1976,292 @@ func (this *SandboxController) SandboxMove() {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|