소스 검색

no message

xingzai 2 년 전
부모
커밋
ad932f6a04
3개의 변경된 파일40개의 추가작업 그리고 32개의 파일을 삭제
  1. 37 31
      controllers/research.go
  2. 1 0
      models/report.go
  3. 2 1
      utils/constants.go

+ 37 - 31
controllers/research.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"encoding/json"
 	"errors"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
@@ -149,10 +150,10 @@ func (this *ResearchController) HotList() {
 	}
 	startSize = utils.StartIndex(currentIndex, pageSize)
 	var condition string
-	if themeType != 2 {
-		condition = `ORDER BY sum_num DESC `
-	} else {
+	if themeType == 2 {
 		condition = `ORDER BY publish_date DESC `
+	} else {
+		condition = `ORDER BY sum_num DESC `
 	}
 
 	total, err := models.GetThemeHeatListCount("")
@@ -280,10 +281,10 @@ func (this *ResearchController) KolList() {
 	}
 
 	var condition string
-	if themeType != 2 {
-		condition = `ORDER BY fllow_num DESC `
-	} else {
+	if themeType == 2 {
 		condition = `ORDER BY sum_num DESC `
+	} else {
+		condition = `ORDER BY fllow_num DESC `
 	}
 
 	list, err := models.GetDepartmentList(condition, user.UserId, startSize, pageSize)
@@ -597,23 +598,26 @@ func (this *ResearchController) 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 = "获取成功"
@@ -651,22 +655,24 @@ func (this *ResearchController) 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 {

+ 1 - 0
models/report.go

@@ -594,6 +594,7 @@ func GetDepartmentList(condition string, userId, startSize, pageSize int) (items
 			d.nick_name,
 			d.department_id,
 			d.img_url,
+			MAX( a.publish_date ) AS publish_date,
 			( SELECT count( 1 ) FROM cygx_article_department_follow AS f  WHERE f.department_id = d.department_id  AND user_id =?  AND f.type= 1  ) AS fllow_num,
 			( SELECT count( 1 ) FROM cygx_article_department_follow  AS f INNER JOIN wx_user AS u ON u.user_id = f.user_id  WHERE f.department_id = d.department_id AND f.type= 1 ) +( SELECT count( 1 ) FROM cygx_article_collect AS ac INNER JOIN wx_user AS u ON u.user_id = ac.user_id  WHERE ac.article_id IN (SELECT article_id FROM cygx_article WHERE department_id = d.department_id ) 	AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS sum_num
 		FROM

+ 2 - 1
utils/constants.go

@@ -107,7 +107,8 @@ const (
 )
 
 const (
-	YAN_XUAN__EXPLAIN = "买方研选内容实行阶段,限时免费。也欢迎您向我们提宝贵建议。"
+	YAN_XUAN_EXPLAIN = "买方研选内容实行阶段,限时免费。也欢迎您向我们提宝贵建议。"
+	YAN_XUAN_TAB_KEY = "yanxuan_header_tab"
 )
 
 const (