xingzai 1 rok pred
rodič
commit
e23bd7d158

+ 22 - 0
models/article_history_record_newpv.go

@@ -205,3 +205,25 @@ func GetCygxArticleHistoryRecordNewpvList(condition string, pars []interface{})
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+type ListPvUvResp struct {
+	ArticleId int `description:"文章ID"`
+	Pv        int `description:"pv"`
+	Uv        int `description:"pv"`
+}
+
+// 列表
+func GetCygxArticleHistoryRecordNewpvListPv(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_newpv  WHERE 1 = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 9 - 5
services/article.go

@@ -165,8 +165,10 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 	}
 
 	articleIds := make([]int, 0)
-	for i := range list {
-		articleIds = append(articleIds, list[i].ArticleId)
+	for _, v := range list {
+		if v.IsSpecial == 0 {
+			articleIds = append(articleIds, v.ArticleId)
+		}
 	}
 	// 报告关联产业信息
 	industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
@@ -214,9 +216,11 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 		//if _, ok := mapCollect[v.ArticleId]; ok {
 		//	list[k].IsCollect = true
 		//}
-		list[k].Pv = articleMapPv[v.ArticleId]
-		list[k].IsCollect = articleCollectMap[v.ArticleId]
-		list[k].CollectNum = articleCollectNumMap[v.ArticleId]
+		if v.IsSpecial == 0 {
+			list[k].Pv = articleMapPv[v.ArticleId]
+			list[k].IsCollect = articleCollectMap[v.ArticleId]
+			list[k].CollectNum = articleCollectNumMap[v.ArticleId]
+		}
 	}
 
 	if len(list) == 0 {

+ 2 - 2
services/article_history.go

@@ -110,13 +110,13 @@ func GetArticleHistoryByArticleId(articleIds []int) (mapResp map[int]int) {
 	var pars []interface{}
 	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
 	pars = append(pars, articleIds)
-	list, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
+	list, err := models.GetCygxArticleHistoryRecordNewpvListPv(condition, pars)
 	if err != nil {
 		return
 	}
 	mapResp = make(map[int]int, 0)
 	for _, v := range list {
-		mapResp[v.ArticleId]++
+		mapResp[v.ArticleId] = v.Pv
 	}
 	return
 }