Browse Source

搜索--弘则推荐

xingzai 3 years ago
parent
commit
af952286f7
2 changed files with 23 additions and 2 deletions
  1. 5 2
      controllers/config.go
  2. 18 0
      models/config.go

+ 5 - 2
controllers/config.go

@@ -20,13 +20,16 @@ func (this *ConfigController) BrowseHistoryList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	configCode := "hot_search"
-	detail, err := models.GetConfigByCode(configCode)
+	detail := new(models.CygxConfig)
+	//configCode := "hot_search"
+	//detail, err := models.GetConfigByCode(configCode)
+	hotSearch, err := models.GetHotSearch()
 	if err != nil {
 		br.Msg = "获取数据失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+	detail.ConfigValue = hotSearch
 	resp := new(models.ConfigResp)
 	resp.Item = detail
 	br.Msg = "获取成功!"

+ 18 - 0
models/config.go

@@ -30,3 +30,21 @@ func GetShowSustainable() (count int, err error) {
 	err = o.Raw(sqlCount).QueryRow(&count)
 	return
 }
+
+// 通过报告精选来获取最新的推荐搜索词
+func GetHotSearch() (permission string, err error) {
+	sql := ` SELECT
+	GROUP_CONCAT(DISTINCT s.subject_name  ORDER BY rl.article_sun_id ASC  SEPARATOR ',') AS subject_name 
+FROM
+	cygx_report_selection_log AS rl
+	INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = rl.industrial_subject_id 
+WHERE
+	rl.article_id = (
+	SELECT
+		MAX( article_id ) 
+FROM
+	cygx_report_selection WHERE publish_status = 1)`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&permission)
+	return
+}