Ver Fonte

查研观向9.9

xingzai há 2 anos atrás
pai
commit
f6b0f6bb93

+ 6 - 9
controllers/article.go

@@ -82,6 +82,12 @@ func (this *ArticleController) Detail() {
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
 		return
 	}
+	lyjhTypeMap, _ := services.GetLyjhTypeMap()
+	if _, ok := lyjhTypeMap[detail.CategoryId]; ok {
+		detail.IsRoadShow = true
+	}
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
+	detail.IsCollect = articleCollectMap[detail.ArticleId]
 	if isSendWx == 1 {
 		var condition string
 		var pars []interface{}
@@ -293,15 +299,6 @@ func (this *ArticleController) Detail() {
 			}
 		}
 
-		collectCount, err := models.GetArticleCollectCount(uid, articleId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-			return
-		}
-		if collectCount > 0 {
-			detail.IsCollect = true
-		}
 		interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"

+ 4 - 0
controllers/report.go

@@ -2143,6 +2143,8 @@ func (this *ReportController) RoadshowDetail() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
+	articleLyjhMap, _ := services.GetLyjhArticleMap()
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
 	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
 	if user.CompanyId > 1 {
 		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
@@ -2157,6 +2159,8 @@ func (this *ReportController) RoadshowDetail() {
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
+		detail.IsCollect = articleCollectMap[detail.ArticleId]
+		detail.IsRoadShow = articleLyjhMap[detail.ArticleId]
 		detail.Body = html.UnescapeString(detail.Body)
 		detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
 		detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")

+ 9 - 10
controllers/user.go

@@ -547,6 +547,8 @@ func (this *UserController) CollectList() {
 		}
 	}
 
+	lyjhTypeMap, _ := services.GetLyjhTypeMap()
+
 	lenList := len(list)
 	for i := 0; i < lenList; i++ {
 		item := list[i]
@@ -565,13 +567,9 @@ func (this *UserController) CollectList() {
 			list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
 			list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
 		}
-		//list[i].TitleEn = article.TitleEn
-		//list[i].UpdateFrequency = article.UpdateFrequency
-		//list[i].CreateDate = article.CreateDate
-		//list[i].Body, _ = services.GetReportContentTextSub(article.Body)
-		//list[i].Abstract = article.Abstract
-		//list[i].CategoryName = article.CategoryName
-		//list[i].SubCategoryName = article.SubCategoryName
+		if _, ok := lyjhTypeMap[item.CategoryId]; ok && list[i].ArticleId >= utils.SummaryArticleId {
+			list[i].IsRoadShow = true
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = list
@@ -1611,9 +1609,9 @@ func (this *UserController) CommnetList() {
 		br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()
 		return
 	}
-
+	articleLyjhMap, _ := services.GetLyjhArticleMap()
+	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
 	resp := new(models.CygxCommentListResp)
-
 	for _, comment := range commentlist {
 		item := models.CygxArticleCommentResp{
 			Id:          comment.Id,
@@ -1636,9 +1634,10 @@ func (this *UserController) CommnetList() {
 		} else if comment.ActivityId > 0 {
 			item.RedirectType = 2
 		}
+		item.IsCollect = articleCollectMap[comment.ArticleId]
+		item.IsRoadShow = articleLyjhMap[comment.ArticleId]
 		resp.List = append(resp.List, &item)
 	}
-
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Success = true

+ 1 - 0
models/article.go

@@ -165,6 +165,7 @@ type ArticleDetail struct {
 	Annotation              string `description:"核心观点"`
 	IsShowFollowButton      bool   `description:"是否展示关注取关按钮"`
 	IsFollowButton          bool   `description:"是否关注"`
+	IsRoadShow              bool   `description:"是否是路演精华"`
 }
 
 type ArticleDetailFileLink struct {

+ 12 - 4
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,15 @@ func GetCygxArticleCollectList(condition string) (items []*CygxArticleCollect, e
 	return
 }
 
-//修改用户收藏文章的相关信息
+// GetCygxArticleCollectByUser 根据用户ID获取所有文章收藏
+func GetCygxArticleCollectByUser(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 +106,7 @@ type CygxArticleCollectCountRep struct {
 	Num       int `description:"数量"`
 }
 
-//获取文章被收藏的数量
+// 获取文章被收藏的数量
 func GetUserArticleCollectList() (items []*CygxArticleCollectCountRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -119,7 +127,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 = ?`

+ 4 - 2
models/article_comment.go

@@ -23,7 +23,7 @@ type CygxArticleComment struct {
 	Title           string    `description:"标题"`
 }
 
-//添加留言
+// 添加留言
 func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -35,7 +35,7 @@ type AddCygxArticleCommentReq struct {
 	Content   string `description:"内容"`
 }
 
-//我的留言列表
+// 我的留言列表
 func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -63,6 +63,8 @@ type CygxArticleCommentResp struct {
 	Content      string    `description:"内容"`
 	Title        string    `description:"标题"`
 	RedirectType int       `description:"跳转类型 1文章 2活动 3产业资源包"`
+	IsCollect    bool      `description:"是否收藏:true,已收藏,false:未收藏"`
+	IsRoadShow   bool      `description:"是否是路演精华"`
 }
 
 type CygxCommentListResp struct {

+ 5 - 0
models/report.go

@@ -297,6 +297,9 @@ type ReportDetailRoadshow struct {
 	Body             string `description:"内容"`
 	CategoryName     string `description:"行业名称"`
 	ReportLink       string `orm:"column(link_article_id)"description:"报告链接"`
+	IsCollect        bool   `description:"是否收藏:true,已收藏,false:未收藏"`
+	IsRoadShow       bool   `description:"是否是路演精华"`
+	CategoryId       int    `description:"文章分类ID"`
 }
 
 type RoadshowDetailResp struct {
@@ -908,6 +911,8 @@ type ArticleReportBillboardResp struct {
 	Pv             int    `description:"PV"`
 	CollectNum     int    `description:"收藏人数"`
 	Source         int    `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
+	IsRoadShow     bool   `description:"是否是路演精华"`
+	CategoryId     int    `description:"分类ID"`
 	List           []*IndustrialManagementIdInt
 }
 

+ 11 - 0
models/report_mapping.go

@@ -253,6 +253,17 @@ WHERE
 	return
 }
 
+// 获取分类
+func GetReportMappingList(condition string, pars []interface{}) (items []*ReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping WHERE  1=1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // 获取所有的报告分类
 func GetReportMappingByPermissionName(chartPermissionName string) (items []*ReportMapping, err error) {
 	o := orm.NewOrm()

+ 12 - 12
models/user.go

@@ -154,7 +154,7 @@ func GetArticleUserCollectCount(userId int) (count int, err error) {
 }
 
 func GetArticleUserCollectList(startSize, pageSize, userId int) (items []*ArticleReportBillboardResp, err error) {
-	sql := `SELECT a.* FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id
+	sql := `SELECT a.*,art.category_id FROM cygx_article_collect AS a INNER JOIN cygx_article as art ON art.article_id = a.article_id
 			WHERE a.user_id=? 
            ORDER BY a.create_time DESC LIMIT ?,? `
 	_, err = orm.NewOrm().Raw(sql, userId, startSize, pageSize).QueryRows(&items)
@@ -239,7 +239,7 @@ func AddCountryCode(CountryCode string, user *WxUserItem) (err error) {
 	return
 }
 
-//修改外呼手机号
+// 修改外呼手机号
 type OutboundMobileItem struct {
 	OutboundMobile      string `description:"外呼手机号"`
 	OutboundCountryCode string `description:"外呼手机号区号"`
@@ -271,7 +271,7 @@ func AddOutboundMobile(item *OutboundMobileItem, userId int) (err error) {
 	return
 }
 
-//用户绑定手机号时同时绑定外呼手机号
+// 用户绑定手机号时同时绑定外呼手机号
 func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ?, country_code= ? WHERE user_id=? `
@@ -279,7 +279,7 @@ func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error)
 	return
 }
 
-//已经绑定手机号,没有绑定外呼手机号的的用户,预约外呼的时候,将外呼手机号同步成手机号
+// 已经绑定手机号,没有绑定外呼手机号的的用户,预约外呼的时候,将外呼手机号同步成手机号
 func BindUserOutboundMobileByMobile(mobile, countryCode string, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? WHERE user_id=? `
@@ -287,7 +287,7 @@ func BindUserOutboundMobileByMobile(mobile, countryCode string, userId int) (err
 	return
 }
 
-//将手机号为11位的用户,区号默认设置为86
+// 将手机号为11位的用户,区号默认设置为86
 func ChangeUserOutboundMobileByMobile(userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET country_code = 86 WHERE user_id=? `
@@ -310,7 +310,7 @@ type UserWhiteListRep struct {
 	List []*UserWhiteList
 }
 
-//获取正式试用用户白名单
+// 获取正式试用用户白名单
 func GetFormalUserWhiteList(fieldStr, condition string) (items []*UserWhiteList, err error) {
 	sql := `SELECT ` + fieldStr + `
 		(SELECT cp.seller_name FROM company_product  AS cp WHERE cp.company_id = u.company_id ORDER BY cp.product_id DESC  LIMIT 0,1 ) as seller_name,
@@ -329,7 +329,7 @@ func GetFormalUserWhiteList(fieldStr, condition string) (items []*UserWhiteList,
 	return
 }
 
-//获取永续用户白名单
+// 获取永续用户白名单
 func GetSustainableUserWhiteList(fieldStr, condition string) (items []*UserWhiteList, err error) {
 	sql := `SELECT ` + fieldStr + `
 			(SELECT cp.seller_name FROM company_product  AS cp WHERE cp.company_id = u.company_id ORDER BY cp.product_id DESC  LIMIT 0,1 ) as seller_name,
@@ -355,7 +355,7 @@ func GetSustainableUserWhiteList(fieldStr, condition string) (items []*UserWhite
 	return
 }
 
-//权益用户
+// 权益用户
 type GetSendEmailAllUserWithRAIRep struct {
 	CompanyName  string `description:"客户名称"`
 	CreditCode   string `description:"社会统一信用码"`
@@ -402,7 +402,7 @@ func GetSendEmailAllUserWithRAI() (items []*GetSendEmailAllUserWithRAIRep, err e
 	return
 }
 
-//权益用户
+// 权益用户
 type GetSendEmailAllUserWithCompanyRep struct {
 	RealName    string `description:"姓名"`
 	Mobile      string `description:"手机号"`
@@ -440,7 +440,7 @@ type Headimgurl struct {
 	Headimgurl string `description:"用户头像"`
 }
 
-//更改用户手机号
+// 更改用户手机号
 func UpdateUserHeadimgurl(headimgurl string, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET headimgurl = ? WHERE user_id=? `
@@ -448,7 +448,7 @@ func UpdateUserHeadimgurl(headimgurl string, userId int) (err error) {
 	return
 }
 
-//更新用户标签
+// 更新用户标签
 func UpdateUserLabel(userLabel string, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET user_label = ? WHERE user_id=? `
@@ -456,7 +456,7 @@ func UpdateUserLabel(userLabel string, userId int) (err error) {
 	return
 }
 
-//更新用户互动量
+// 更新用户互动量
 func UpdateUserInteractionNum(interactionNum, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET interaction_num = ? WHERE user_id=? `

+ 33 - 0
services/articlt_collect.go

@@ -0,0 +1,33 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+//func init() {
+//	GetCygxArticleCollectMap(90)
+//}
+
+// GetCygxArticleCollectMap 根据用户ID获取所有文章收藏
+func GetCygxArticleCollectMap(userId int) (mapResp map[int]bool, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("根据用户ID获取所有文章收藏失败 ErrMsg:"+err.Error(), 2)
+
+		}
+	}()
+	list, e := models.GetCygxArticleCollectByUser(userId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("根据用户ID获取所有文章收藏,GetCygxArticleCollectByUser " + e.Error())
+		return
+	}
+	mapResp = make(map[int]bool, 0)
+	if len(list) > 0 {
+		for _, v := range list {
+			mapResp[v.ArticleId] = true
+		}
+	}
+	return
+}

+ 62 - 0
services/industrial_management.go

@@ -670,3 +670,65 @@ func IndustrialManagementHotMapGropuPermission() (mapResp map[int]bool, err erro
 	}
 	return
 }
+
+// GetLyjhTypeMap 获取路演精华对应分类ID
+func GetLyjhTypeMap() (mapResp map[int]int, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("获取路演精华对应分类ID失败 ErrMsg:"+err.Error(), 2)
+
+		}
+	}()
+	condition := " AND match_type_name = '路演精华'  "
+	var pars []interface{}
+	list, e := models.GetReportMappingList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+		return
+	}
+	mapResp = make(map[int]int, 0)
+	if len(list) > 0 {
+		for _, v := range list {
+			mapResp[v.CategoryId] = v.CategoryId
+		}
+	}
+	return
+}
+
+// GetLyjhArticleMap 获取路演精华对应文章ID
+func GetLyjhArticleMap() (mapResp map[int]bool, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("获取路演精华对应文章ID失败 ErrMsg:"+err.Error(), 2)
+		}
+	}()
+	condition := " AND match_type_name = '路演精华'  "
+	var pars []interface{}
+	list, e := models.GetReportMappingList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+		return
+	}
+	var categoryId []int
+	mapResp = make(map[int]bool, 0)
+	if len(list) > 0 {
+		for _, v := range list {
+			categoryId = append(categoryId, v.CategoryId)
+		}
+	}
+	lencategoryId := len(categoryId)
+	if lencategoryId > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.category_id IN (` + utils.GetOrmInReplace(lencategoryId) + `)`
+		pars = append(pars, categoryId)
+		listArticle, e := models.GetHomeList(condition, pars, 0, 1000)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		for _, v := range listArticle {
+			mapResp[v.ArticleId] = true
+		}
+	}
+	return
+}