Browse Source

no message

xingzai 2 years ago
parent
commit
ed776fec5f

+ 1 - 1
controllers/home.go

@@ -208,7 +208,7 @@ func (this *MobileHomeController) List() {
 			br.Msg = "获取帖子数据失败,Err:" + err.Error()
 			return
 		}
-		listPublic, err = services.HandleArticleCategoryImg(listPublic)
+		listPublic, err = services.HandleArticleCategoryImg(listPublic, user)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()

+ 1 - 1
controllers/report.go

@@ -868,7 +868,7 @@ func (this *MobileReportController) SearchReport() {
 		return
 	}
 	//return
-	list, err = services.HandleArticleCategoryImg(list)
+	list, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()

+ 2 - 2
controllers/report_billboard.go

@@ -7,7 +7,7 @@ import (
 	"time"
 )
 
-//报告榜单
+// 报告榜单
 type ReportBillboardController struct {
 	BaseAuthController
 }
@@ -134,7 +134,7 @@ func (this *MobileReportBillboardController) ReadList() {
 	}
 	var err error
 	resp := new(models.ReportBillboardListResp)
-	resp.List, err = services.HandleArticleCategoryImg(list)
+	resp.List, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()

+ 93 - 6
controllers/research.go

@@ -115,7 +115,7 @@ func (this *MobileResearchController) ArticleNewList() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	list, err = services.HandleArticleCategoryImg(list)
+	list, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
@@ -319,7 +319,7 @@ func (this *MobileResearchController) HotList() {
 			}
 		}
 		if v.FllowNum > 0 {
-			list[k].IsFollw = true
+			list[k].IsFollow = true
 		}
 		for _, v2 := range listSubjcet {
 			if v2.IndustrialManagementId == v.IndustrialManagementId {
@@ -391,7 +391,7 @@ func (this *MobileResearchController) ThemeDetail() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	list, err = services.HandleArticleCategoryImg(list)
+	list, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
@@ -435,7 +435,7 @@ func (this *MobileResearchController) ThemeDetail() {
 		return
 	}
 	if _, ok := userFollowIndustrialMap[industrialManagementId]; ok {
-		resp.IsFollw = true
+		resp.IsFollow = true
 	}
 
 	//处理文章关联的标的
@@ -521,7 +521,7 @@ func (this *MobileResearchController) DepartmentIdDetail() {
 	resp.ArticleNum = detail.ArticleNum
 	resp.CollectNum = detail.CollectNum
 	if detail.MyFllowNum > 0 {
-		resp.IsFllow = true
+		resp.IsFollow = true
 	}
 
 	condition = `  AND a.department_id = ` + strconv.Itoa(departmentId)
@@ -538,7 +538,7 @@ func (this *MobileResearchController) DepartmentIdDetail() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	list, err = services.HandleArticleCategoryImg(list)
+	list, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
@@ -686,3 +686,90 @@ func (this *MobileResearchController) FllowDepartment() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 研选月度收藏榜
+// @Description 研选月度收藏榜接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Success 200 {object} models.ReportBillboardListResp
+// @router /article/billboard [get]
+func (this *MobileResearchController) Billboard() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize", 15)
+	var condition string
+	var pars []interface{}
+	articleTypeIds, err := services.GetYanXuanArticleTypeIds()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
+		return
+	}
+	if articleTypeIds != "" {
+		condition = ` AND a.article_type_id IN (` + articleTypeIds + `)  `
+	} else {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "研选分类ID不能为空"
+		return
+	}
+	condition += `   AND a.article_type_id IN (` + articleTypeIds + `) `
+	// 根据关注时间一个月前至昨日的增量数据排序
+	nowTime := time.Now().Local()
+	startTime := nowTime.AddDate(0, -1, 0)
+	endTime := nowTime.AddDate(0, 0, -1)
+	condition += ` AND ac.create_time BETWEEN ? AND ?`
+	pars = append(pars, startTime, endTime)
+	list, err := models.GetReportCollectionBillboardListYx(pageSize, pars, condition)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + err.Error()
+		return
+	}
+	list, err = services.HandleArticleCategoryImg(list, user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
+		return
+	}
+	//处理对应的文章类型标签按钮
+	nameMap, styleMap, err := services.GetArticleTypeMap()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.ArticleResearchListResp)
+	for _, v := range list {
+		item := models.ArticleResearchResp{
+			ArticleId:       v.ArticleId,
+			ArticleTypeId:   v.ArticleTypeId,
+			Title:           v.Title,
+			PublishDate:     v.PublishDate,
+			DepartmentId:    v.DepartmentId,
+			NickName:        v.NickName,
+			IsCollect:       v.IsCollect,
+			Pv:              v.Pv,
+			CollectNum:      v.CollectNum,
+			Abstract:        v.Abstract,
+			Annotation:      v.Annotation,
+			ImgUrlPc:        v.ImgUrlPc,
+			ArticleTypeName: nameMap[v.ArticleTypeId],
+			ButtonStyle:     styleMap[v.ArticleTypeId],
+			List:            v.List,
+		}
+		resp.List = append(resp.List, &item)
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 12 - 5
models/article_collect.go

@@ -21,7 +21,7 @@ type CygxArticleCollect struct {
 	RealName        string `description:"用户实际名称"`
 }
 
-//添加收藏信息
+// 添加收藏信息
 func AddCygxArticleCollect(item *CygxArticleCollect) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -79,7 +79,14 @@ func GetCygxArticleCollectList(condition string) (items []*CygxArticleCollect, e
 	return
 }
 
-//修改用户收藏文章的相关信息
+func GetCygxArticleCollectListByUser(userId int) (items []*CygxArticleCollect, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_collect  WHERE 1 =1   AND article_id > 0 AND user_id = ? `
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+// 修改用户收藏文章的相关信息
 func UpdateCygxArticleCollect(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string
@@ -98,7 +105,7 @@ type CygxArticleCollectCountRep struct {
 	Num       int `description:"数量"`
 }
 
-//获取文章被收藏的数量
+// 获取文章被收藏的数量
 func GetUserArticleCollectList() (items []*CygxArticleCollectCountRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -119,7 +126,7 @@ func GetUserArticleCollectList() (items []*CygxArticleCollectCountRep, err error
 	return
 }
 
-//修改文章收藏的数量
+// 修改文章收藏的数量
 func UpdateArticleCollectCountNum(num, articleId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_article SET user_collection_num = ? WHERE article_id = ?`
@@ -169,4 +176,4 @@ func GetVideoCollectCount(userId, videoId int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_article_collect WHERE user_id=? AND video_id=? `
 	err = orm.NewOrm().Raw(sql, userId, videoId).QueryRow(&count)
 	return
-}
+}

+ 2 - 2
models/article_department.go

@@ -104,7 +104,7 @@ type DepartmentDetailResp struct {
 	FllowNum       int    `description:"多少人关注"`
 	ArticleNum     int    `description:"文章数量"`
 	CollectNum     int    `description:"收藏人数"`
-	IsFllow        bool   `description:"是否关注"`
+	IsFollow       bool   `description:"是否关注"`
 	List           []*ArticleResearchResp
 	ListIndustrial []*IndustrialManagementNewResp
 	Paging         *paging.PagingItem
@@ -124,7 +124,7 @@ type DepartmentDetail struct {
 	FllowNum     int    `description:"多少人关注"`
 	ArticleNum   int    `description:"文章数量"`
 	CollectNum   int    `description:"收藏人数"`
-	IsFllow      bool   `description:"是否关注"`
+	IsFollow     bool   `description:"是否关注"`
 	MyFllowNum   int    `description:"本人是否关注"`
 }
 

+ 15 - 19
models/report.go

@@ -64,20 +64,6 @@ type SearchResourceResp struct {
 	ListYx []*IndustrialManagement `description:"研选"`
 }
 
-//用户收藏榜start
-//type IndustrialManagementHotResp struct {
-//	IndustrialManagementId int                  `orm:"column(industrial_management_id);pk" description:"产业id"`
-//	IndustryName           string               `description:"产业名称"`
-//	IsFollw                bool                 `description:"是否关注"`
-//	FllowNum               int                  `description:"关注数量"`
-//	IsNew                  bool                 `description:"是否新标签"`
-//	IsHot                  bool                 `description:"是否新标签"`
-//	PublishDate            string               `description:"发布时间"`
-//	ArticleReadNum         int                  `description:"文章阅读数量"`
-//	Source                 int                  `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
-//	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
-//}
-
 // 获取列表数量
 func GetReoprtSearchCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
@@ -300,7 +286,7 @@ func GetSearchResourceListHz(condition string, startSize, pageSize int) (items [
 type IndustrialManagementHotResp struct {
 	IndustrialManagementId int                  `orm:"column(industrial_management_id);pk" description:"产业id"`
 	IndustryName           string               `description:"产业名称"`
-	IsFollw                bool                 `description:"是否关注"`
+	IsFollow               bool                 `description:"是否关注"`
 	FllowNum               int                  `description:"关注数量"`
 	IsNew                  bool                 `description:"是否新标签"`
 	IsHot                  bool                 `description:"是否新标签"`
@@ -351,16 +337,26 @@ func GetReportCollectionBillboardListYx(limit int, pars []interface{}, condition
 	o := orm.NewOrm()
 	sql := `SELECT
 			ac.id,
-			a.article_id,
 			a.category_id,
+			'买方研选' as chart_permission_name,
+			a.article_id,
 			a.title,
+			a.body,
 			a.annotation,
+			a.abstract,
 			a.publish_date,
-			'买方研选' as chart_permission_name,
-			COUNT(ac.id) AS collection_num
+			a.article_type_id,
+			d.nick_name,
+			d.department_id,
+			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac  INNER JOIN wx_user as u ON  u.user_id = ac.user_id  WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collection_num
 		FROM
 			cygx_article AS a
 			INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id 
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
 		WHERE
 			1 = 1 
 			AND a.publish_status = 1  AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId)
@@ -613,7 +609,7 @@ type GetThemeAericleListResp struct {
 type GetThemeDetailResp struct {
 	IndustrialManagementId int                  `description:"产业Id"`
 	IndustryName           string               `description:"产业名称"`
-	IsFollw                bool                 `description:"是否关注"`
+	IsFollow               bool                 `description:"是否关注"`
 	ListSubject            []*IndustrialSubject `description:"标的列表"`
 	List                   []*ArticleResearchResp
 }

+ 9 - 0
routers/commentsRouter.go

@@ -385,6 +385,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
+        beego.ControllerComments{
+            Method: "Billboard",
+            Router: `/article/billboard`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileResearchController"],
         beego.ControllerComments{
             Method: "ArticleNewList",

+ 27 - 1
services/article.go

@@ -82,7 +82,7 @@ func GetReportContentTextArticleBody(content string) (contentSub string) {
 }
 
 // HandleArticleCategoryImg 预处理文章的封面图片
-func HandleArticleCategoryImg(list []*models.ArticleListResp) (items []*models.ArticleListResp, err error) {
+func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUserItem) (items []*models.ArticleListResp, err error) {
 	//研选的五张图片
 	detailResearch, e := models.GetConfigByCode("category_research_img_url")
 	if e != nil {
@@ -117,6 +117,7 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp) (items []*models.A
 	for _, v := range reportMappingList {
 		mapChartPerssion[strconv.Itoa(v.CategoryId)] = v.ChartPermissionName
 	}
+
 	for k, v := range list {
 		if list[k].Annotation == "" {
 			imgurl, _ := FixArticleImgUrl(html.UnescapeString(list[k].Body))
@@ -187,12 +188,22 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp) (items []*models.A
 			})
 		}
 	}
+	// 处理文章收藏字段
+	mapCollect, e := GetUserAticleCollectMap(user)
+	if e != nil {
+		err = errors.New("GetUserAticleCollectMap" + e.Error())
+		return
+	}
+
 	for k, v := range list {
 		if len(industryMap[v.ArticleId]) > 0 {
 			list[k].List = industryMap[v.ArticleId]
 		} else {
 			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
 		}
+		if _, ok := mapCollect[v.ArticleId]; ok {
+			list[k].IsCollect = true
+		}
 	}
 
 	if len(list) == 0 {
@@ -459,3 +470,18 @@ func GetYanXuanArticleTypeIds() (articleTypeIds string, err error) {
 	}
 	return
 }
+
+// GetUserAticleCollectMap 获取用户收藏的文章ID
+func GetUserAticleCollectMap(user *models.WxUserItem) (respMap map[int]int, err error) {
+	list, e := models.GetCygxArticleCollectListByUser(user.UserId)
+	if e != nil {
+		err = errors.New("GetCygxArticleCollectListByUser, Err: " + e.Error())
+		return
+	}
+	articleMap := make(map[int]int)
+	for _, v := range list {
+		articleMap[v.ArticleId] = v.ArticleId
+	}
+	respMap = articleMap
+	return
+}

+ 1 - 1
services/resource_data.go

@@ -101,7 +101,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			return
 		}
 
-		articleList, e = HandleArticleCategoryImg(articleList)
+		articleList, e = HandleArticleCategoryImg(articleList, user)
 		if e != nil {
 			err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
 			return