|
@@ -241,12 +241,22 @@ func (this *EnglishReportController) AddClassify() {
|
|
|
br.ErrMsg = "该名称已存在!"
|
|
|
return
|
|
|
}
|
|
|
- _, err = models.AddEnglishClassify(item)
|
|
|
+ var newId int64
|
|
|
+ newId, err = models.AddEnglishClassify(item)
|
|
|
if err != nil {
|
|
|
br.Msg = "保存失败"
|
|
|
br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ if parentId == 0 { //一级目录的rootId等于自己本身
|
|
|
+ item.RootId = int(newId)
|
|
|
+ err = item.UpdateEnglishClassify([]string{"RootId"})
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存失败"
|
|
|
+ br.ErrMsg = "保存失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
@@ -297,7 +307,7 @@ func (this *EnglishReportController) EditClassify() {
|
|
|
}
|
|
|
if oldItem.ParentId == 0 && parentId > 0 {
|
|
|
// 一级分类变更为二级分类,禁止
|
|
|
- br.Msg = "一级分类不允许更改为二级分类"
|
|
|
+ br.Msg = "一级分类不允许更改为二级分类或三级分类"
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -314,6 +324,14 @@ func (this *EnglishReportController) EditClassify() {
|
|
|
br.ErrMsg = "获取信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ //二级分类不允许改成三级分类
|
|
|
+ if oldItem.ParentId > 0 && oldItem.ParentId == oldItem.RootId {
|
|
|
+ if parent.ParentId > 0 && parent.ParentId != parent.RootId {
|
|
|
+ //即将改为为三级分类
|
|
|
+ br.Msg = "二级分类不允许更改为三级分类"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if parent.RootId == 0 {
|
|
|
rootId = parent.Id
|
|
@@ -336,6 +354,9 @@ func (this *EnglishReportController) EditClassify() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if parentId == 0 { //一级分类的顶级分类为自己的ID
|
|
|
+ rootId = oldItem.Id
|
|
|
+ }
|
|
|
item := &models.EnglishClassify{
|
|
|
Id: oldItem.Id,
|
|
|
ClassifyName: classifyName,
|