Parcourir la source

过滤禁用的分类

xyxie il y a 1 an
Parent
commit
556b2627af

+ 12 - 12
models/tables/rddp/classify/query.go

@@ -5,10 +5,11 @@ import (
 	"hongze/hongze_yb/utils"
 )
 
-func GetSimpleAll()(list []*Classify, err error)  {// 过滤权益研报的分类
-	err = global.MYSQL["rddp"].Select("id, classify_name, yb_icon_url, yb_bg_url, parent_id").Model(Classify{}).Where("is_show = 1  AND parent_id != 56 AND id != 56").Scan(&list).Error
+func GetSimpleAll() (list []*Classify, err error) { // 过滤权益研报的分类
+	err = global.MYSQL["rddp"].Select("id, classify_name, yb_icon_url, yb_bg_url, parent_id").Model(Classify{}).Where("is_show = 1 AND enabled = 1  AND parent_id != 56 AND id != 56").Scan(&list).Error
 	return
 }
+
 // GetByClassifyName 根据分类名称查找专栏详情
 func GetByClassifyName(classifyName string) (item *Classify, err error) {
 	err = global.MYSQL["rddp"].Model(Classify{}).Where("classify_name = ?", classifyName).First(&item).Error
@@ -30,7 +31,7 @@ func GetByClassifyNameFirst(classifyName string) (item *Classify, err error) {
 // GetSecondIdsByClassifyNames 根据权限相关的二级分类名称获取名称ID
 func GetSecondIdsByClassifyNames(names []string) (ids []int, err error) {
 	var list []*Classify
-	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("classify_name in (?) and parent_id >0 AND is_show = 1 AND parent_id != 56", names).Scan(&list).Error
+	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("classify_name in (?) and parent_id >0 AND is_show = 1 AND enabled = 1 AND parent_id != 56", names).Scan(&list).Error
 	if err != nil {
 		if err == utils.ErrNoRow {
 			err = nil
@@ -47,7 +48,7 @@ func GetSecondIdsByClassifyNames(names []string) (ids []int, err error) {
 func GetParentList() (list []*Classify, err error) {
 	err = global.MYSQL["rddp"].Model(Classify{}).
 		Select("id, classify_name, show_type, yb_ficc_icon, yb_ficc_pc_icon, yb_ficc_sort").
-		Where("parent_id = 0 and classify_name != '权益研报' AND is_show = 1").
+		Where("parent_id = 0 and classify_name != '权益研报' AND is_show = 1 AND enabled = 1").
 		Order("sort asc, id asc").Scan(&list).Error
 	if err == utils.ErrNoRow {
 		err = nil
@@ -57,7 +58,7 @@ func GetParentList() (list []*Classify, err error) {
 
 // GetByClassifyId 根据分类ID查询分类详情
 func GetByClassifyId(id int) (item *Classify, err error) {
-	err = global.MYSQL["rddp"].Model(Classify{}).Where("id = ? AND is_show = 1", id).First(&item).Error
+	err = global.MYSQL["rddp"].Model(Classify{}).Where("id = ? AND is_show = 1 AND enabled = 1", id).First(&item).Error
 	if err == utils.ErrNoRow {
 		err = nil
 	}
@@ -68,18 +69,17 @@ func GetByClassifyId(id int) (item *Classify, err error) {
 func GetListByPid(pid int) (list []*Classify, err error) {
 	err = global.MYSQL["rddp"].Model(Classify{}).
 		Select("id, classify_name, parent_id, abstract, report_author, author_descript, home_img_url, vip_title, avatar_img_url").
-		Where("parent_id = ? AND is_show = 1 ", pid).Order("sort asc, id asc").Scan(&list).Error
+		Where("parent_id = ? AND is_show = 1 AND enabled = 1", pid).Order("sort asc, id asc").Scan(&list).Error
 	if err == utils.ErrNoRow {
 		err = nil
 	}
 	return
 }
 
-
 // GetIdsByClassifyNameAndParentId 查询
 func GetIdsByClassifyNameAndParentId(names []string, parentId int) (ids []int, err error) {
 	var list []*Classify
-	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("classify_name in (?) and parent_id = ? AND is_show = 1", names, parentId).Scan(&list).Error
+	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("classify_name in (?) and parent_id = ? AND is_show = 1 AND enabled = 1", names, parentId).Scan(&list).Error
 	if err != nil {
 		return
 	}
@@ -92,7 +92,7 @@ func GetIdsByClassifyNameAndParentId(names []string, parentId int) (ids []int, e
 // GetOtherIdsByClassifyNames 查询
 func GetOtherIdsByClassifyNames(names []string) (ids []int, err error) {
 	var list []*Classify
-	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("classify_name in (?) and parent_id > 0 AND is_show = 1", names).Scan(&list).Error
+	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("classify_name in (?) and parent_id > 0 AND is_show = 1 AND enabled = 1", names).Scan(&list).Error
 	if err != nil {
 		return
 	}
@@ -105,7 +105,7 @@ func GetOtherIdsByClassifyNames(names []string) (ids []int, err error) {
 // GetOtherIdsByClassifyNames 查询
 func GetOtherSecondIds(names []string) (ids []int, err error) {
 	var list []*Classify
-	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("parent_id IN (SELECT id FROM classify WHERE classify_name IN (?) AND parent_id = 0 AND is_show = 1)", names).Scan(&list).Error
+	err = global.MYSQL["rddp"].Model(Classify{}).Select("id").Where("parent_id IN (SELECT id FROM classify WHERE classify_name IN (?) AND parent_id = 0 AND is_show = 1 AND enabled = 1)", names).Scan(&list).Error
 	if err != nil {
 		return
 	}
@@ -117,7 +117,7 @@ func GetOtherSecondIds(names []string) (ids []int, err error) {
 
 // GetChildByPid 根据一级分类查找二级分类
 func GetChildByPid(pid int) (list []*Classify, err error) {
-	err = global.MYSQL["rddp"].Model(Classify{}).Where("parent_id = ? AND is_show = 1 ", pid).Scan(&list).Error
+	err = global.MYSQL["rddp"].Model(Classify{}).Where("parent_id = ? AND is_show = 1 AND enabled = 1", pid).Scan(&list).Error
 	if err == utils.ErrNoRow {
 		err = nil
 	}
@@ -128,4 +128,4 @@ func GetChildByPid(pid int) (list []*Classify, err error) {
 func GetClassifyList() (list []*Classify, err error) {
 	err = global.MYSQL["rddp"].Model(Classify{}).Scan(&list).Error
 	return
-}
+}

+ 1 - 0
models/tables/rddp/report/query.go

@@ -376,6 +376,7 @@ WHERE
 	r.classify_name_first = c.classify_name
 	AND c.show_type = 2
 	AND c.is_show = 1
+    AND c.enabled = 1
 	AND state IN (2, 6)
 	ORDER BY publish_time DESC LIMIT 1
 	`

+ 8 - 9
models/tables/report_chapter_type/query.go

@@ -5,9 +5,9 @@ import (
 	"hongze/hongze_yb/utils"
 )
 
-func GetEffectTypeID() (chapterIds []int, err error ) {
+func GetEffectTypeID() (chapterIds []int, err error) {
 	var chapterList []*ReportChapterType
-	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Select("report_chapter_type_id ").Where("is_show=1").Scan(&chapterList).Error
+	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Select("report_chapter_type_id ").Where("is_show=1 AND enabled = 1").Scan(&chapterList).Error
 	if err != nil {
 		if err == utils.ErrNoRow {
 			err = nil
@@ -22,16 +22,15 @@ func GetEffectTypeID() (chapterIds []int, err error ) {
 	return
 }
 
-
-func GetEffectTypes() (list []*ReportChapterType, err error ) {
-	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Where("is_show=1").Scan(&list).Error
+func GetEffectTypes() (list []*ReportChapterType, err error) {
+	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Where("is_show=1 AND enabled = 1").Scan(&list).Error
 	return
 }
 
 // GetTypeIDByReportChapterTypeName 根据章节类型查找章节ID
-func GetTypeIDByReportChapterTypeName(name string) (chapterIds []int, err error ) {
+func GetTypeIDByReportChapterTypeName(name string) (chapterIds []int, err error) {
 	var chapterList []*ReportChapterType
-	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Select("report_chapter_type_id ").Where("is_show=1 and report_chapter_type_name =?", name).Scan(&chapterList).Error
+	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Select("report_chapter_type_id ").Where("is_show=1 AND enabled = 1 and report_chapter_type_name =?", name).Scan(&chapterList).Error
 	if err != nil {
 		if err == utils.ErrNoRow {
 			err = nil
@@ -47,7 +46,7 @@ func GetTypeIDByReportChapterTypeName(name string) (chapterIds []int, err error
 }
 
 // GetTickerTitleByTypeId 根据类型获取指标标题
-func GetTickerTitleByTypeId(id int) (chapterType *ReportChapterType , err error)  {
+func GetTickerTitleByTypeId(id int) (chapterType *ReportChapterType, err error) {
 	err = global.DEFAULT_MYSQL.Model(ReportChapterType{}).Select("ticker_title, report_chapter_type_id, report_chapter_type_name, report_chapter_type_key").Where("report_chapter_type_id=?", id).First(&chapterType).Error
 	if err != nil {
 		if err == utils.ErrNoRow {
@@ -56,4 +55,4 @@ func GetTickerTitleByTypeId(id int) (chapterType *ReportChapterType , err error)
 		return
 	}
 	return
-}
+}