浏览代码

研选内容的筛选

xingzai 2 年之前
父节点
当前提交
0e25f27a9a
共有 2 个文件被更改,包括 33 次插入26 次删除
  1. 30 26
      controllers/research.go
  2. 3 0
      utils/constants.go

+ 30 - 26
controllers/research.go

@@ -31,23 +31,26 @@ func (this *MobileResearchController) ArticleType() {
 		br.Ret = 408
 		return
 	}
-	var condition string
-	condition = " AND is_show_yanx  = 1 "
-	list, err := models.GetCygxArticleTypeListCondition(condition)
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+	key := utils.YAN_XUAN_TAB_KEY
+	conf, e := models.GetConfigByCode(key)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error()
 		return
 	}
-	resp := new(models.CygxArticleTypeListResp)
-	for _, v := range list {
-		item := models.CygxArticleTypeResp{
-			ArticleTypeId:   v.ArticleTypeId,
-			ArticleTypeName: v.ArticleTypeName,
-			ButtonStyle:     v.ButtonStyle,
-		}
-		resp.List = append(resp.List, &item)
+	if conf.ConfigValue == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值有误"
+		return
+	}
+	list := new(models.CygxArticleTypeListResp)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
+		return
 	}
+	resp := new(models.CygxArticleTypeListResp)
+	resp = list
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -85,22 +88,24 @@ func (this *MobileResearchController) ArticleNewList() {
 	}
 	startSize = paging.StartIndex(currentIndex, pageSize)
 	var condition string
+	var conditiontype string
 	var pars []interface{}
 	condition = `    AND publish_status = 1  `
 	if articleTypeIds == "" {
-		var conditiontype string
 		conditiontype = " AND is_show_yanx  = 1 "
-		listType, err := models.GetCygxArticleTypeListCondition(conditiontype)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-			return
-		}
-		for _, v := range listType {
-			articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
-		}
-		articleTypeIds = strings.TrimRight(articleTypeIds, ",")
+	} else {
+		conditiontype = ` AND   group_id IN  (` + articleTypeIds + `) `
 	}
+	listType, err := models.GetCygxArticleTypeListCondition(conditiontype)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range listType {
+		articleTypeIds += strconv.Itoa(v.ArticleTypeId) + ","
+	}
+	articleTypeIds = strings.TrimRight(articleTypeIds, ",")
 	condition += `   AND a.article_type_id IN (` + articleTypeIds + `) `
 	total, err := models.GetArticleResearchCount(condition, pars)
 	if err != nil {
@@ -108,7 +113,6 @@ func (this *MobileResearchController) ArticleNewList() {
 		br.ErrMsg = "GetArticleResearchCount,Err:" + err.Error()
 		return
 	}
-
 	list, err := models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
 	if err != nil {
 		br.Msg = "获取信息失败"

+ 3 - 0
utils/constants.go

@@ -120,6 +120,9 @@ const (
 
 var YAN_XUAN_ARTICLE_TYPE_ID = []int{1, 2, 12}
 
+const (
+	YAN_XUAN_TAB_KEY = "yanxuan_header_tab"
+)
 const (
 	YD_TOKEN = "yidong_token"
 )