|
@@ -848,6 +848,9 @@ func (this *ChartClassifyController) ChartClassifyMove() {
|
|
|
br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ oldParentId := chartClassifyInfo.ParentId
|
|
|
+ oldLevelPath := chartClassifyInfo.LevelPath
|
|
|
+ oldSelected := chartClassifyInfo.IsSelected
|
|
|
|
|
|
// 校验移动的父级目录下是否有重名分类
|
|
|
exists, e := data_manage.GetChartClassifyByParentIdAndName(req.ParentClassifyId, chartClassifyInfo.ChartClassifyName, req.ClassifyId)
|
|
@@ -886,14 +889,18 @@ func (this *ChartClassifyController) ChartClassifyMove() {
|
|
|
}
|
|
|
updateCol := make([]string, 0)
|
|
|
|
|
|
- //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
|
|
|
- if chartClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
|
|
|
- parentChartClassifyInfo, err := data_manage.GetChartClassifyById(req.ParentClassifyId)
|
|
|
+ var parentChartClassifyInfo *data_manage.ChartClassify
|
|
|
+ if req.ParentClassifyId > 0 {
|
|
|
+ parentChartClassifyInfo, err = data_manage.GetChartClassifyById(req.ParentClassifyId)
|
|
|
if err != nil {
|
|
|
br.Msg = "移动失败"
|
|
|
br.ErrMsg = "获取上级分类信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ }
|
|
|
+ //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
|
|
|
+ if chartClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
|
|
|
+
|
|
|
chartClassifyInfo.ParentId = parentChartClassifyInfo.ChartClassifyId
|
|
|
chartClassifyInfo.Level = parentChartClassifyInfo.Level + 1
|
|
|
chartClassifyInfo.ModifyTime = time.Now()
|
|
@@ -966,6 +973,23 @@ func (this *ChartClassifyController) ChartClassifyMove() {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+ if oldParentId != req.ParentClassifyId {
|
|
|
+ if err = data.UpdateChartClassifyLevelPathWithChildren(chartClassifyInfo, parentChartClassifyInfo, oldParentId, oldLevelPath); err != nil {
|
|
|
+ br.Msg = "修改分类失败"
|
|
|
+ br.ErrMsg = "更新分类level_path失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果是精选目录,则需要同步到ETA资源库
|
|
|
+ if chartClassifyInfo.Source == utils.CHART_SOURCE_DEFAULT {
|
|
|
+ // 如果当前目录的精选标识发生变化,需要同步更新子目录的精选标识
|
|
|
+ if err = data.UpdateChildClassifySelection(chartClassifyInfo, parentChartClassifyInfo, oldSelected); err != nil {
|
|
|
+ br.Msg = "修改分类失败"
|
|
|
+ br.ErrMsg = "更新子目录精选标识失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ go eta_forum.ChartClassifySaveBatch(chartClassifyInfo.Source)
|
|
|
+ }
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "移动成功"
|