Browse Source

no message

zhangchuanxing 3 months ago
parent
commit
0cb4ef9609
4 changed files with 14 additions and 9 deletions
  1. 1 1
      controllers/report.go
  2. 3 2
      controllers/research.go
  3. 6 4
      models/industrial_management.go
  4. 4 2
      models/report.go

+ 1 - 1
controllers/report.go

@@ -294,7 +294,7 @@ func (this *MobileReportController) IndustryList() {
 		//endTime := nowTime.AddDate(0, 0, -1)
 		//condition += ` AND idf.create_time BETWEEN ? AND ?`
 		//parsBd = append(parsBd, startTime, endTime)
-		list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
+		list, e = models.GetTopIndustryFollowData(uid, 0, pageSize, condition, parsBd)
 		if e != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()

+ 3 - 2
controllers/research.go

@@ -349,11 +349,12 @@ func (this *MobileResearchController) HotList() {
 		br.ErrMsg = "研选分类ID不能为空"
 		return
 	}
+	conditionOrder = ` ORDER BY follow_type_order DESC ,  `
 	condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
 	if themeType == 2 {
-		conditionOrder = `ORDER BY publish_date DESC  `
+		conditionOrder += ` publish_date DESC  `
 	} else {
-		conditionOrder = `ORDER BY sum_num DESC   `
+		conditionOrder += ` sum_num DESC   `
 	}
 
 	total, err := models.GetThemeHeatListCount(condition)

+ 6 - 4
models/industrial_management.go

@@ -348,20 +348,22 @@ func GetTopOneMonthArtReadNumIndustryAll(condition string, pars []interface{}) (
 //}
 
 // GetTopIndustryFollowData 获取关注度最高的产业关注数据
-func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []interface{}) (list []*IndustrialManagement, err error) {
+func GetTopIndustryFollowData(uid, startSize, pageSize int, condition string, pars []interface{}) (list []*IndustrialManagement, err error) {
 	sql := `SELECT
-				man.*
+				man.*,
+				IFNULL( f.follow_type_order, 0 ) AS follow_type_order 
 			FROM  cygx_industrial_management AS man
+			LEFT JOIN cygx_industry_fllow AS f ON f.industrial_management_id = man.industrial_management_id AND f.user_id = ? 
 			WHERE 1 = 1 `
 	if condition != "" {
 		sql += condition
 	}
 	sql += ` GROUP BY
 				man.industrial_management_id
-			ORDER BY
+			ORDER BY  follow_type_order DESC ,
 				man.one_month_follow_num DESC , man.industrial_management_id DESC 
 			LIMIT ?,?`
-	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	_, err = orm.NewOrm().Raw(sql, uid, pars, startSize, pageSize).QueryRows(&list)
 	return
 }
 

+ 4 - 2
models/report.go

@@ -1138,6 +1138,7 @@ func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, p
 			m.article_read_num,
           	MAX( a.publish_date ) AS publish_date,
 			MIN(a.publish_date) AS min_report_time,
+			IFNULL( f.follow_type_order, 0 ) AS follow_type_order,
 			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND user_id =? AND f.type = 1  ) AS fllow_num,
 			m.yanxuan_article_read_num + m.activity_num AS sum_num
 		FROM
@@ -1145,10 +1146,11 @@ func GetThemeHeatList(userId int, condition, conditionOrder string, startSize, p
 			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
 			LEFT JOIN cygx_article AS a ON a.article_id = mg.article_id 
 			LEFT JOIN cygx_industrial_activity_group_management as ag ON ag.industrial_management_id = mg.industrial_management_id
+			LEFT JOIN cygx_industry_fllow AS f ON f.industrial_management_id = m.industrial_management_id AND f.user_id = ? 
 		WHERE
 			1 = 1
-			AND publish_status = 1  ` + condition + `  GROUP BY m.industrial_management_id ` + conditionOrder + ` , last_updated_time  DESC LIMIT ?,?`
-	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+			AND publish_status = 1  ` + condition + `  GROUP BY m.industrial_management_id   ` + conditionOrder + ` , last_updated_time  DESC LIMIT ?,?`
+	_, err = o.Raw(sql, userId, userId, startSize, pageSize).QueryRows(&items)
 	return
 }