浏览代码

no message

xingzai 2 年之前
父节点
当前提交
99a014f177
共有 2 个文件被更改,包括 59 次插入12 次删除
  1. 35 12
      controllers/report.go
  2. 24 0
      models/industrial_management.go

+ 35 - 12
controllers/report.go

@@ -132,9 +132,8 @@ func (this *MobileReportController) TradeList() {
 // @Title 产业报告分类列表接口
 // @Description 获取产业报告分类列表接口
 // @Param   ChartPermissionId   query   int  true       "分类ID"
-// @Param   IsNewLabel   query   string  false       "是否属于新标签,1是,0否"
-// @Param   IsDeepLabel   query   string  false       "是否属于深标签,1是,0否"
-// @Param   OrderColumn   query   string  false       "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
+// @Param   DeepCover   query   string  false       "是否选择深度覆盖,1是,0否 不填默认为0"
+// @Param   RecommendFocus   query   string  false       "是否选择推荐关注,1是,0否 不填默认为0"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Success 200 {object} models.IndustrialManagementList
@@ -155,10 +154,10 @@ func (this *MobileReportController) IndustryList() {
 	ChartPermissionId, _ := this.GetInt("ChartPermissionId")
 	orderColumn := this.GetString("OrderColumn")
 	orderColumnNew := this.GetString("OrderColumn")
-	isNewLabel := this.GetString("IsNewLabel")
-	isDeepLabel := this.GetString("IsDeepLabel")
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
+	deepCover, _ := this.GetInt("DeepCover")
+	recommendFocus, _ := this.GetInt("RecommendFocus")
 	var orderSrt string
 	var condition string
 	var startSize int
@@ -171,16 +170,40 @@ func (this *MobileReportController) IndustryList() {
 	}
 
 	startSize = paging.StartIndex(currentIndex, pageSize)
-	if isNewLabel == "1" {
-		condition += ` AND is_new_label = ` + isNewLabel
-	}
-	if isDeepLabel == "1" {
-		condition += ` AND is_deep_label = ` + isDeepLabel
-	}
-
 	if ChartPermissionId > 0 {
 		condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
 	}
+	// 深度覆盖
+	if deepCover == 1 {
+		// 查询深标签产业报告数
+		var deepCondition string
+		var deepPars []interface{}
+		deepCondition += ` AND man.is_deep_label = 1`
+		if ChartPermissionId > 0 {
+			deepCondition += ` AND man.chart_permission_id = ?`
+			deepPars = append(deepPars, ChartPermissionId)
+		}
+		industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
+		if e != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
+			return
+		}
+		deepIdArr := make([]string, 0)
+		for i := range industryCountList {
+			if industryCountList[i].ArtNum > 10 {
+				deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
+			}
+		}
+		deepIds := strings.Join(deepIdArr, ",")
+		if deepIds != "" {
+			condition = `AND man.industrial_management_id IN (` + deepIds + `)`
+		}
+	}
+	// 推荐关注
+	if recommendFocus == 1 {
+		condition += ` AND man.recommended_index >= 50`
+	}
 
 	var list []*models.IndustrialManagement
 	total, err := models.GetIndustrialManagementAllCount(condition)

+ 24 - 0
models/industrial_management.go

@@ -69,6 +69,12 @@ type IndustrialManagementResp struct {
 	IndustryName           string `description:"产业名称"`
 }
 
+// IndustryArtCount 产业文章数
+type IndustryArtCount struct {
+	ArtNum                 int `json:"art_num" description:"文章数"`
+	IndustrialManagementId int `json:"industrial_management_id" description:"产业ID"`
+}
+
 //产业列表
 func GetIndustrialManagementAllCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
@@ -241,3 +247,21 @@ func GetIndustrialListByarticleId(pars []interface{}, condition string) (items [
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// GetIndustryArtCountByCondition 获取产业文章关联的文章数
+func GetIndustryArtCountByCondition(condition string, pars []interface{}) (list []*IndustryArtCount, err error) {
+	sql := `SELECT
+				COUNT(1) AS art_num,
+				agm.industrial_management_id
+			FROM
+				cygx_industrial_article_group_management AS agm
+			JOIN cygx_industrial_management AS man ON man.industrial_management_id = agm.industrial_management_id
+			WHERE
+				1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY agm.industrial_management_id`
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}