浏览代码

no message

xingzai 1 年之前
父节点
当前提交
9fd75349f8
共有 6 个文件被更改,包括 234 次插入132 次删除
  1. 143 94
      controllers/user.go
  2. 1 5
      controllers/wechat.go
  3. 27 26
      models/report.go
  4. 58 5
      models/user.go
  5. 2 0
      services/article.go
  6. 3 2
      utils/config.go

+ 143 - 94
controllers/user.go

@@ -1117,6 +1117,14 @@ func (this *UserController) BrowseHistoryList() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
 	userId := this.User.UserId
 	var pageSize, currentIndex, startSize int
 	pageSize, _ = this.GetInt("PageSize")
@@ -1142,10 +1150,11 @@ func (this *UserController) BrowseHistoryList() {
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+
 	resp := new(models.ArticleReportBillboardLIstPageResp)
 	if len(list) == 0 {
 		page := paging.GetPaging(currentIndex, pageSize, total)
-		resp.List = list
+		resp.List = make([]*models.ArticleReportBillboardResp, 0)
 		resp.Paging = page
 		br.Msg = "获取成功!"
 		br.Ret = 200
@@ -1154,110 +1163,150 @@ func (this *UserController) BrowseHistoryList() {
 		return
 	}
 
-	var articleIds []string
-	var condition string
-	var pars []interface{}
-	for _, v := range list {
-		articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
-	}
-	articleIdStr := strings.Join(articleIds, ",")
-
-	//获取文章关联的产业
-	pars = make([]interface{}, 0)
-	condition = ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(articleIds)) + ` )  `
-	pars = append(pars, articleIds)
-	industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
+	list, err = services.HandleArticleCategoryImg(list, user)
 	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
 		return
 	}
-	industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
-	if len(industrialList) > 0 {
-		for _, v := range industrialList {
-			item := new(models.IndustrialManagementIdInt)
-			item.ArticleId = v.ArticleId
-			if v.ArticleId > utils.SummaryArticleId {
-				item.IsResearch = true
-			}
-			item.IndustrialManagementId = v.IndustrialManagementId
-			item.IndustryName = v.IndustryName
-			item.ChartPermissionId = v.ChartPermissionId
-			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
-		}
-	}
-	for k, v := range list {
-		if len(industrialMap[v.ArticleId]) > 0 {
-			list[k].List = industrialMap[v.ArticleId]
-		} else {
-			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
-		}
-	}
 
-	articleMap := make(map[int]*models.ArticleDetail)
-	if articleIdStr != "" {
-		articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
-		if err != nil {
-			br.Msg = "获取数据失败"
-			br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
-			return
-		}
-		for _, v := range articleList {
-			if _, ok := articleMap[v.ArticleId]; !ok {
-				articleMap[v.ArticleId] = v
-			}
-		}
-	}
-
-	//处理文章PV收藏等数量
-	mapArticleCollectNum := make(map[int]*models.CygxArticleNum)
-	if len(articleIds) > 0 {
-		articleCollectNumList, err := models.GetArticleCollectNum(articleIds, userId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,GetArticleCollectNum Err:" + err.Error()
-			return
-		}
-		for _, v := range articleCollectNumList {
-			mapArticleCollectNum[v.ArticleId] = v
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	for _, v := range list {
+		item := models.ArticleReportBillboardResp{
+			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,
+			ImgUrlPc:            v.ImgUrlPc,
+			LabelKeywordImgLink: v.LabelKeywordImgLink,
+			List:                v.List,
+			SpecialColumnId:     v.SpecialColumnId,
 		}
-	}
-
-	//研选的五张图片
-	detailResearch, err := models.GetConfigByCode("category_research_img_url")
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,GetConfigByCode Err:" + err.Error()
-		return
-	}
-	researchList := strings.Split(detailResearch.ConfigValue, "{|}")
-	lenList := len(list)
-	for i := 0; i < lenList; i++ {
-		item := list[i]
-		article := articleMap[item.ArticleId]
-		knum := item.ArticleId % 5
-		list[i].ImgUrlPc = researchList[knum]
-		if article != nil {
-			list[i].Title = article.Title
-			list[i].PublishDate = utils.TimeRemoveHms2(article.PublishDate)
-			list[i].DepartmentId = article.DepartmentId
-			list[i].NickName = article.NickName
-			if article.ArticleId < utils.SummaryArticleId {
-				list[i].Source = 1
+		if v.IsSpecial == 1 {
+			item.IsSpecial = true
+			item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
+			if v.CompanyTags != "" {
+				item.CompanyTags = strings.Split(v.CompanyTags, ",")
 			} else {
-				list[i].Source = 2
+				item.CompanyTags = []string{}
 			}
-
-			if mapArticleCollectNum[article.ArticleId] != nil {
-				list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
-				list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
-				list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
+			if v.IndustryTags != "" {
+				item.IndustryTags = strings.Split(v.IndustryTags, ",")
+			} else {
+				item.IndustryTags = []string{}
 			}
+			//item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
+			//if v.SpecialType == 1 {
+			//	item.Title = "【笔记】" + item.Title
+			//} else if v.SpecialType == 2 {
+			//	item.Title = "【观点】" + item.Title
+			//}
+			//if v.MyCollectNum > 0 {
+			//	item.IsCollect = true
+			//}
 		}
+
+		resp.List = append(resp.List, &item)
 	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
 
-	resp.List = list
+	//var articleIds []string
+	//var condition string
+	//var pars []interface{}
+	//for _, v := range list {
+	//	if v.IsSpecial == 1 {
+	//		//if v.CompanyTags != "" {
+	//		//	v.CompanyTags = strings.Split(v.CompanyTags, ",")
+	//		//} else {
+	//		//	v.CompanyTags = []string{}
+	//		//}
+	//	} else {
+	//		articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
+	//	}
+	//}
+	//articleIdStr := strings.Join(articleIds, ",")
+	//
+	////获取文章关联的产业
+	//pars = make([]interface{}, 0)
+	//condition = ` AND mg.article_id IN (  ` + utils.GetOrmInReplace(len(articleIds)) + ` )  `
+	//pars = append(pars, articleIds)
+	//industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
+	//if err != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
+	//	return
+	//}
+	//industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
+	//if len(industrialList) > 0 {
+	//	for _, v := range industrialList {
+	//		item := new(models.IndustrialManagementIdInt)
+	//		item.ArticleId = v.ArticleId
+	//		item.IndustrialManagementId = v.IndustrialManagementId
+	//		item.IndustryName = v.IndustryName
+	//		item.ChartPermissionId = v.ChartPermissionId
+	//		industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
+	//	}
+	//}
+	//for k, v := range list {
+	//	if len(industrialMap[v.ArticleId]) > 0 {
+	//		list[k].List = industrialMap[v.ArticleId]
+	//	} else {
+	//		list[k].List = make([]*models.IndustrialManagementIdInt, 0)
+	//	}
+	//}
+	//
+	//articleMap := make(map[int]*models.ArticleDetail)
+	//if articleIdStr != "" {
+	//	articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
+	//	if err != nil {
+	//		br.Msg = "获取数据失败"
+	//		br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
+	//		return
+	//	}
+	//	for _, v := range articleList {
+	//		if _, ok := articleMap[v.ArticleId]; !ok {
+	//			articleMap[v.ArticleId] = v
+	//		}
+	//	}
+	//}
+	//
+	////处理文章PV收藏等数量
+	//mapArticleCollectNum := make(map[int]*models.CygxArticleNum)
+	//if len(articleIds) > 0 {
+	//	articleCollectNumList, err := models.GetArticleCollectNum(articleIds, userId)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		br.Msg = "获取失败"
+	//		br.ErrMsg = "获取失败,GetArticleCollectNum Err:" + err.Error()
+	//		return
+	//	}
+	//	for _, v := range articleCollectNumList {
+	//		mapArticleCollectNum[v.ArticleId] = v
+	//	}
+	//}
+	//
+	//lenList := len(list)
+	//for i := 0; i < lenList; i++ {
+	//	item := list[i]
+	//	article := articleMap[item.ArticleId]
+	//	if article != nil {
+	//		list[i].Title = article.Title
+	//		list[i].PublishDate = utils.TimeRemoveHms2(article.PublishDate)
+	//		list[i].DepartmentId = article.DepartmentId
+	//		list[i].NickName = article.NickName
+	//		if mapArticleCollectNum[article.ArticleId] != nil {
+	//			list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
+	//			list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
+	//			list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
+	//		}
+	//	}
+	//}
+	//page := paging.GetPaging(currentIndex, pageSize, total)
+	//
+	//resp.List = list
 	resp.Paging = page
 	br.Msg = "获取成功!"
 	br.Ret = 200

+ 1 - 5
controllers/wechat.go

@@ -94,11 +94,7 @@ func (this *WechatCommonController) WechatLogin() {
 	items.City = wxUserInfo.City
 	items.Country = wxUserInfo.Country
 	items.Headimgurl = wxUserInfo.Headimgurl
-	if isWechat == 0 {
-		items.CreatePlatform = 7
-	} else {
-		items.CreatePlatform = 8
-	}
+	items.CreatePlatform = utils.WxPlatform
 	items.CreateTime = time.Now()
 	if total == 0 {
 		_, err = models.AddUserRecord(items)

+ 27 - 26
models/report.go

@@ -793,32 +793,33 @@ func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []
 
 // 报告榜单start
 type ArticleReportBillboardResp struct {
-	ArticleId       int      `description:"文章id"`
-	Title           string   `description:"标题"`
-	PublishDate     string   `description:"发布时间"`
-	PermissionName  string   `description:"行业名称"`
-	DepartmentId    int      `description:"作者Id"`
-	NickName        string   `description:"作者昵称"`
-	IsCollect       bool     `description:"本人是否收藏"`
-	Pv              int      `description:"PV"`
-	CollectNum      int      `description:"收藏人数"`
-	Source          int      `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
-	ArticleTypeId   int      `description:"文章类型ID判断是否是研选使用"`
-	IsResearch      bool     `description:"是否属于研选"`
-	ArticleTypeName string   `description:"文章类型名称"`
-	IsSpecial       bool     `description:"是否为研选专栏"`
-	IsSpecialInt    int      `description:"是否为研选专栏"`
-	SpecialTags     string   `description:"研选专栏标签"`
-	MyCollectNum    int      `description:"本人是否收藏"`
-	SpecialType     int      `description:"专栏类型 1:笔记,2:观点"`
-	UserId          int      `description:"作者id"`
-	IndustryTagStr  string   `description:"研选专栏行业标签"`
-	CompanyTagsStr  string   `description:"研选专栏公司标签"`
-	IndustryTags    []string `description:"研选专栏行业标签"`
-	CompanyTags     []string `description:"研选专栏公司标签"`
-	SpecialColumnId int      `description:"专栏栏目id"`
-	ImgUrlPc        string   `description:"图片链接"`
-	List            []*IndustrialManagementIdInt
+	ArticleId           int      `description:"文章id"`
+	Title               string   `description:"标题"`
+	PublishDate         string   `description:"发布时间"`
+	PermissionName      string   `description:"行业名称"`
+	DepartmentId        int      `description:"作者Id"`
+	NickName            string   `description:"作者昵称"`
+	IsCollect           bool     `description:"本人是否收藏"`
+	Pv                  int      `description:"PV"`
+	CollectNum          int      `description:"收藏人数"`
+	Source              int      `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	ArticleTypeId       int      `description:"文章类型ID判断是否是研选使用"`
+	IsResearch          bool     `description:"是否属于研选"`
+	ArticleTypeName     string   `description:"文章类型名称"`
+	IsSpecial           bool     `description:"是否为研选专栏"`
+	IsSpecialInt        int      `description:"是否为研选专栏"`
+	SpecialTags         string   `description:"研选专栏标签"`
+	MyCollectNum        int      `description:"本人是否收藏"`
+	SpecialType         int      `description:"专栏类型 1:笔记,2:观点"`
+	UserId              int      `description:"作者id"`
+	IndustryTagStr      string   `description:"研选专栏行业标签"`
+	CompanyTagsStr      string   `description:"研选专栏公司标签"`
+	IndustryTags        []string `description:"研选专栏行业标签"`
+	CompanyTags         []string `description:"研选专栏公司标签"`
+	SpecialColumnId     int      `description:"专栏栏目id"`
+	ImgUrlPc            string   `description:"图片链接"`
+	LabelKeywordImgLink string   `description:"标签关键词ico"`
+	List                []*IndustrialManagementIdInt
 }
 
 type ArticleReportBillboardLIstPageResp struct {

+ 58 - 5
models/user.go

@@ -444,11 +444,64 @@ func GetArticleUserBrowseHistoryCount(userId int, endDate string) (count int, er
 	return
 }
 
-func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleReportBillboardResp, err error) {
-	sql := `SELECT a.* ,	MAX( a.id ) AS mid   FROM  cygx_article as art INNER JOIN  cygx_article_history_record_newpv AS a     ON  art.article_id = a.article_id AND  article_type_id  > 0 
-			WHERE a.user_id=? AND a.create_time>=?  GROUP BY a.article_id
-           ORDER BY mid  DESC LIMIT ?,? `
-	_, err = orm.NewOrm().Raw(sql, userId, endDate, startSize, pageSize).QueryRows(&items)
+//func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleReportBillboardResp, err error) {
+//	sql := `SELECT a.* ,	MAX( a.id ) AS mid   FROM  cygx_article as art INNER JOIN  cygx_article_history_record_newpv AS a     ON  art.article_id = a.article_id AND  article_type_id  > 0
+//			WHERE a.user_id=? AND a.create_time>=?  GROUP BY a.article_id
+//           ORDER BY mid  DESC LIMIT ?,? `
+//	_, err = orm.NewOrm().Raw(sql, userId, endDate, startSize, pageSize).QueryRows(&items)
+//	return
+//}
+
+func GetArticleUserBrowseHistoryList(startSize, pageSize, userId int, endDate string) (items []*ArticleListResp, err error) {
+	sql := `SELECT
+			art.article_id,
+			art.article_type_id,
+			art.title,
+			art.publish_date,
+			'' AS company_tags, 
+			'' AS industry_tags,
+			art.department_id,
+			d.nick_name,
+			0 AS is_special,
+			0 as pv,
+			0 as collect_num,
+			a.create_time 
+		FROM
+			cygx_article AS art
+			INNER JOIN cygx_article_history_record_newpv AS a ON art.article_id = a.article_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = art.department_id 
+		WHERE
+			a.user_id = ? 
+			AND a.create_time >= ?
+			AND art.article_type_id > 0 
+		GROUP BY
+			art.article_id UNION ALL
+		SELECT
+			art.id AS article_id,
+			- 1 AS article_type_id,
+			art.title,
+			art.publish_time AS publish_date,
+			art.company_tags AS company_tags, 
+			art.industry_tags AS industry_tags,
+			d.id AS department_id,
+			d.nick_name,
+			1 AS is_special,
+			art.pv,
+			art.article_collect_num as collect_num,
+			a.create_time 
+		FROM
+			cygx_yanxuan_special AS art
+			INNER JOIN cygx_yanxuan_special_record AS a ON art.id = a.yanxuan_special_id
+			INNER JOIN cygx_yanxuan_special_author AS d ON d.user_id = art.user_id 
+		WHERE
+			a.user_id = ? 
+			AND a.create_time >= ? 
+		GROUP BY
+			art.id 
+		ORDER BY
+			create_time DESC 
+			LIMIT  ?,? `
+	_, err = orm.NewOrm().Raw(sql, userId, endDate, userId, endDate, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 2 - 0
services/article.go

@@ -171,6 +171,8 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp, user *models.WxUse
 			} else {
 				list[k].LabelKeywordImgLink = utils.LABEL_ICO_5
 			}
+		} else {
+			list[k].LabelKeywordImgLink = utils.LABEL_ICO_4
 		}
 	}
 

+ 3 - 2
utils/config.go

@@ -54,6 +54,7 @@ var (
 // 模板消息推送
 var (
 	SendWxTemplateMsgUrl string
+	WxPlatform           = 11 //注册平台,1:日度点评公众号,2:管理后台,3:pc端网站,4:查研观向小程序 ,11:买方研选网页版
 )
 
 func init() {
@@ -99,8 +100,8 @@ func init() {
 	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,18955528215"
 	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829"
 	if RunMode == "release" {
-		WxPublicAppId = "wxb7cb8a15abad5b8e"                                          //查研观向小助手
-		WxPublicAppSecret = "f425ba2863084249722af1e2a5cfffd3"                        //查研观向小助手
+		WxPublicAppId = "wx2f85cdbe74585222"                                          //买方研选公众号AppId
+		WxPublicAppSecret = "98e4a09c9ba6a0b34e0df3192ba1aba3"                        //买方研选公众号AppSecret
 		WxMsgTemplateIdApplyXzs = "IpS-yuNNQc8osCoy20jPHNkvBUyKRL1NGn7c0G9xmQA"       //申请待处理(小助手)
 		WxMsgTemplateIdApplyCancelXzs = "gCSCAWNNhjkzE2V1cjbIV_Ex68R_8LM_u25qDlSKWyM" ////预约取消提醒(小助手)
 		WxMsgTemplateIdApply = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"