xingzai 1 yıl önce
ebeveyn
işleme
d07a2c2590

+ 22 - 0
models/article_history_record_newpv.go

@@ -302,3 +302,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
+}

+ 4 - 4
services/article_history.go

@@ -25,13 +25,13 @@ func GetArticleHistoryByUser(articleIds []int, user *models.WxUserItem) (mapResp
 	var pars []interface{}
 	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenIds) + `) AND  user_id = ?`
 	pars = append(pars, articleIds, user.UserId)
-	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
 }
@@ -52,13 +52,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
 }

+ 1 - 1
services/resource_data.go

@@ -144,7 +144,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			err = errors.New("GetReportSelectionListHome, Err: " + e.Error())
 			return
 		}
-		mapPv := GetCygxReportHistoryRecordListMap(minutessummaryIds, "bzyjhz")
+		mapPv := GetCygxReportHistoryRecordListMap(researchsummaryIds, "bzyjhz")
 		for _, v := range listresearchsummary {
 			v.Pv = mapPv[v.ArticleId]
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)