Browse Source

fix:新增子分类的时候,继承的章节类型需要包含已经禁用的章节类型

Roc 9 months ago
parent
commit
3500be5ede
2 changed files with 17 additions and 3 deletions
  1. 15 1
      models/report_chapter_type.go
  2. 2 2
      services/classify.go

+ 15 - 1
models/report_chapter_type.go

@@ -468,7 +468,7 @@ func (r *ReportChapterType) SetEnabled(id, enabled int) (err error) {
 }
 
 // GetReportChapterTypeListByClassifyId
-// @Description: 通过报告类型获取章节类型列表
+// @Description: 通过报告类型获取章节类型列表(已启用的)
 // @author: Roc
 // @datetime 2024-06-03 16:00:12
 // @param classifyId int
@@ -480,3 +480,17 @@ func GetReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapter
 	_, err = o.Raw(sql, classifyId).QueryRows(&list)
 	return
 }
+
+// GetAllReportChapterTypeListByClassifyId
+// @Description: 通过报告类型获取所有的章节类型列表
+// @author: Roc
+// @datetime 2024-06-03 16:00:12
+// @param classifyId int
+// @return list []*ReportChapterType
+// @return err error
+func GetAllReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapterType, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` SELECT * FROM report_chapter_type WHERE report_classify_id = ? `
+	_, err = o.Raw(sql, classifyId).QueryRows(&list)
+	return
+}

+ 2 - 2
services/classify.go

@@ -409,7 +409,7 @@ func moveReportByAddClassify(parentClassifyInfo, currClassifyInfo *models.Classi
 	pars = append(pars, currClassifyInfo.Id, currClassifyInfo.ClassifyName, parentClassifyInfo.Id)
 
 	// 获取当前分类下的所有章节类型
-	currReportChapterTypeList, err := models.GetReportChapterTypeListByClassifyId(currClassifyInfo.Id)
+	currReportChapterTypeList, err := models.GetAllReportChapterTypeListByClassifyId(currClassifyInfo.Id)
 	if err != nil {
 		return
 	}
@@ -441,7 +441,7 @@ func inheritReportChapterType(parentClassifyId, currClassifyId int) (err error)
 			utils.FileLog.Error(fmt.Sprint("继承父级分类下的章节类型失败,父级分类ID:", parentClassifyId, ";当前分类ID:", currClassifyId, ";错误信息:", err.Error()))
 		}
 	}()
-	parentReportChapterTypeList, err := models.GetReportChapterTypeListByClassifyId(parentClassifyId)
+	parentReportChapterTypeList, err := models.GetAllReportChapterTypeListByClassifyId(parentClassifyId)
 	if err != nil {
 		return
 	}