Ver Fonte

展示精选资源目录修改

xyxie há 3 semanas atrás
pai
commit
fa69592dbb
1 ficheiros alterados com 4 adições e 12 exclusões
  1. 4 12
      models/data_manage/chart_classify.go

+ 4 - 12
models/data_manage/chart_classify.go

@@ -604,10 +604,6 @@ func GetChartClassifyIdListByAdminId(adminId, source int) (chartClassifyIdList [
 
 // GetChartClassifyAndInfoByParentId
 func GetChartClassifyAndInfoByParentId(parentId int, isSelected int) (items []*ChartClassifyItems, err error) {
-	where := ""
-	if isSelected == utils.ChartClassifyIsSelected {
-		where = " AND is_selected = 1"
-	}
 	sql := ` SELECT
 	0 AS chart_info_id,
 	chart_classify_id,
@@ -634,7 +630,7 @@ func GetChartClassifyAndInfoByParentId(parentId int, isSelected int) (items []*C
 FROM
 	chart_classify 
 WHERE
-	parent_id = ? and source = 1` + where + ` UNION ALL
+	parent_id = ? and source = 1 AND is_selected = ?  UNION ALL
 SELECT
 	chart_info_id,
 	chart_classify_id,
@@ -665,16 +661,12 @@ WHERE
 ORDER BY
 	sort ASC,
 	chart_classify_id ASC`
-	err = global.DbMap[utils.DbNameIndex].Raw(sql, parentId, parentId).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, parentId, parentId, isSelected).Find(&items).Error
 	return
 }
 
 // GetChartClassifyAndInfoByParentId
 func GetChartClassifyAndInfoByParentIdForMe(parentId, adminId, isSelected int) (items []*ChartClassifyItems, err error) {
-	where := ""
-	if isSelected == utils.ChartClassifyIsSelected {
-		where = " AND is_selected = 1"
-	}
 	sql := ` SELECT
 	0 AS chart_info_id,
 	chart_classify_id,
@@ -693,7 +685,7 @@ func GetChartClassifyAndInfoByParentIdForMe(parentId, adminId, isSelected int) (
 FROM
 	chart_classify 
 WHERE
-	parent_id = ? and source = 1` + where + ` UNION ALL
+	parent_id = ? and source = 1 AND is_selected = ? UNION ALL
 SELECT
 	chart_info_id,
 	chart_classify_id,
@@ -716,7 +708,7 @@ WHERE
 ORDER BY
 	sort ASC,
 	chart_classify_id ASC`
-	err = global.DbMap[utils.DbNameIndex].Raw(sql, parentId, parentId, adminId).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, parentId, parentId, adminId, isSelected).Find(&items).Error
 	return
 }