xingzai 1 gadu atpakaļ
vecāks
revīzija
57b1744591

+ 8 - 1
controllers/report_billboard.go

@@ -8,7 +8,7 @@ import (
 	"time"
 )
 
-//报告榜单
+// 报告榜单
 type ReportBillboardController struct {
 	BaseAuthController
 }
@@ -341,6 +341,10 @@ func (this *ReportBillboardController) ReadList() {
 		articleIds = append(articleIds, list[i].ArticleId)
 	}
 
+	articleMapPv := services.GetArticleHistoryByArticleId(articleIds)                       //文章Pv
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
+	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
+
 	// 报告关联产业信息
 	industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
 	if len(articleIds) > 0 {
@@ -369,6 +373,9 @@ func (this *ReportBillboardController) ReadList() {
 		} else {
 			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
 		}
+		v.Pv = articleMapPv[v.ArticleId]
+		v.IsCollect = articleCollectMap[v.ArticleId]
+		v.CollectNum = articleCollectNumMap[v.ArticleId]
 	}
 
 	resp := new(models.ArticleReportBillboardLIstResp)

+ 2 - 1
controllers/tactics.go

@@ -86,7 +86,7 @@ func (this *TacticsController) List() {
 		}
 	}
 	ArticleHistoryMap := services.GetArticleHistoryByUser(articleIds, user)
-	ProductInteriorHistoryMap := services.GetCygxProductInteriorHistoryListMap(articleIds, user)
+	ProductInteriorHistoryMap := services.GetCygxProductInteriorHistoryListMap(productInteriorIs, user)
 	for k, v := range list {
 		if v.Resource == 1 {
 			if ArticleHistoryMap[v.ArticleId] == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
@@ -124,6 +124,7 @@ func (this *TacticsController) List() {
 		}
 		if v.Resource == 2 {
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+			v.Pv = ProductInteriorHistoryMap[v.ArticleId]
 		}
 	}
 	resp.List = list

+ 13 - 2
models/product_interior_history.go

@@ -27,13 +27,24 @@ func AddCygxProductInteriorHistory(item *CygxProductInteriorHistory) (lastId int
 	return
 }
 
+type ListProductInteriorPvUvResp struct {
+	ProductInteriorId int `description:"文章ID"`
+	Pv                int `description:"pv"`
+	Uv                int `description:"pv"`
+}
+
 // 列表
-func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*CygxProductInteriorHistory, err error) {
+func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*ListProductInteriorPvUvResp, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_product_interior_history as art WHERE 1= 1 `
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			product_interior_id
+		FROM
+			cygx_product_interior_history  WHERE 1 = 1  `
 	if condition != "" {
 		sql += condition
 	}
+	sql += ` GROUP BY product_interior_id `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 2 - 2
services/product_interior.go

@@ -215,7 +215,7 @@ func GetCygxProductInteriorHistoryListMap(productInteriorIs []int, user *models.
 	}
 	mapPv = make(map[int]int, 0)
 	for _, v := range list {
-		mapPv[v.ProductInteriorId]++
+		mapPv[v.ProductInteriorId] = v.Pv
 	}
 	return
 }
@@ -243,7 +243,7 @@ func GetCygxProductInteriorHistoryListPvMap(productInteriorIs []int) (mapPv map[
 	}
 	mapPv = make(map[int]int, 0)
 	for _, v := range list {
-		mapPv[v.ProductInteriorId]++
+		mapPv[v.ProductInteriorId] = v.Pv
 	}
 	return
 }