xingzai 2 ani în urmă
părinte
comite
4d514a2639
2 a modificat fișierele cu 54 adăugiri și 20 ștergeri
  1. 10 7
      controllers/report.go
  2. 44 13
      services/article.go

+ 10 - 7
controllers/report.go

@@ -1549,11 +1549,10 @@ func (this *ReportController) Detail() {
 	isBestNew, _ := this.GetBool("IsBestNew")
 	if isBestNew {
 		tbdb := "cygx_report_selection"
-		reportTypeStr := "bgjx"
+		//reportTypeStr := "bgjx"
 		condition := ` AND publish_status = 1  `
 		var pars []interface{}
-		readSql := ` (SELECT COUNT(1) AS  count  FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND  report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
-		list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, 0, 1)
+		list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -1563,10 +1562,9 @@ func (this *ReportController) Detail() {
 			articleId = v.ArticleId
 		}
 	}
-
-	if articleId < 0 {
-		br.Msg = "参数错误"
-		br.ErrMsg = "参数错误"
+	if articleId < 1 {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
 		return
 	}
 	resp := new(models.ReportSelectionLetailResp)
@@ -1591,6 +1589,11 @@ func (this *ReportController) Detail() {
 		return
 	}
 
+	if detail.ReportLink != "" {
+		articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
+		detail.CeLueArticleId = articleIdLink
+	}
+
 	//较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
 	var isAllNew bool // 判断是否都打新的标签
 	lastPeriods := detail.Periods - 1

+ 44 - 13
services/article.go

@@ -77,7 +77,7 @@ func GetReportContentTextSubNew(content string) (contentSub string, err error) {
 	return
 }
 
-//GetReportContentTextSubByarticle 解析文章内容
+// GetReportContentTextSubByarticle 解析文章内容
 func GetReportContentTextSubByarticle(content, abstract string, articleId int) (contentSub string, err error) {
 	var lenabstract int
 	//如果不是研选就这么展示
@@ -104,7 +104,7 @@ func GetReportContentTextSubByarticle(content, abstract string, articleId int) (
 
 }
 
-//解析文章内容
+// 解析文章内容
 func GetArticleAll() {
 	var err error
 	defer func() {
@@ -123,7 +123,7 @@ func GetArticleAll() {
 	}
 }
 
-//解析报告
+// 解析报告
 func FixArticleContent(articleId int) {
 	item, err := models.GetArticleDetailById(articleId)
 	if err != nil {
@@ -320,7 +320,7 @@ func FixArticleImgUrl(body string) (contentSub string, err error) {
 	return
 }
 
-//获取标签里的第一个内容
+// 获取标签里的第一个内容
 func FixArticleFirstCount(body string) (contentSub string, err error) {
 
 	doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
@@ -370,7 +370,7 @@ func SynchronizationArtclehistory() {
 	fmt.Println("同步结束")
 }
 
-//统计报表
+// 统计报表
 func StatisticalReport() {
 	var isSummaryNumAll, isClassNum, pvNumAll, uvNumAll int
 	list, err := models.GetChartPermissionActivity()
@@ -555,7 +555,7 @@ func PushViewRecordNewRedisData(reportViewRecord *ReportViewRecord, companyId in
 //	fmt.Println(sum)
 //}
 
-//获取策略平台报告阅读数据
+// 获取策略平台报告阅读数据
 func GetCeLueArticlePv(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
@@ -684,7 +684,7 @@ func init122() {
 
 }
 
-//处理同步过来的文章
+// 处理同步过来的文章
 func HandleArticleListByApi(artcleId int) (err error) {
 	defer func() {
 		if err != nil {
@@ -1161,7 +1161,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 //	DoArticleOnenIdWxTemplateMsg(6940)
 //}
 
-//过滤策略平台报告,研选报告重复推送,以及权限勾选的推送
+// 过滤策略平台报告,研选报告重复推送,以及权限勾选的推送
 func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 	//策略平台同步过来的文章ID,做微信模板消息推送,同一篇报告12小时只推送一次
 	cacheKey := fmt.Sprint(utils.CACHE_KEY_ARTICLE_ID_TEMPLATE, ":ArticleId", articleId)
@@ -1591,7 +1591,7 @@ func DoArticleOnenIdWxTemplateMsg(articleId int) (err error) {
 	return
 }
 
-//GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
+// GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
 func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
 	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
 	if e != nil {
@@ -1621,7 +1621,7 @@ func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *mode
 //	GetArticNewLabelWhithActivity3Month()
 //}
 
-//弘则报告发布日期在三个月以内的
+// 弘则报告发布日期在三个月以内的
 func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	var condition string
 	var pars []interface{}
@@ -1670,7 +1670,7 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	return
 }
 
-//HandleArticleCategoryImg 预处理文章的封面图片
+// HandleArticleCategoryImg 预处理文章的封面图片
 func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeArticle, err error) {
 	//研选的五张图片
 	detailResearch, e := models.GetConfigByCode("category_research_img_url")
@@ -1808,7 +1808,7 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 	return
 }
 
-//处理核心观点的展示规则
+// 处理核心观点的展示规则
 func ArticleAnnotation(item *models.HomeArticle) (annotation string) {
 	if item.ArticleId >= utils.SummaryArticleId {
 		item.Annotation = YxArticleAnnotation(item)
@@ -1881,7 +1881,7 @@ func ArticleAnnotation(item *models.HomeArticle) (annotation string) {
 	return
 }
 
-//解析研选内容中的核心观点
+// 解析研选内容中的核心观点
 func YxArticleAnnotation(article *models.HomeArticle) (annotation string) {
 	//如果不规范,就获取内容主体
 	if strings.Count(article.Body, "<hr") == 0 {
@@ -1932,3 +1932,34 @@ func YxArticleAnnotation(article *models.HomeArticle) (annotation string) {
 	annotation = body
 	return
 }
+
+// 通过接解析带有Md5的文章链接获取文章ID
+func GetReportLinkToArticleid(reportLink string) (articleId int, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("通过接解析带有Md5的文章链接获取文章ID失败"+err.Error(), 2)
+		}
+	}()
+	var artMd5 string
+	//处理报告的
+	strnum1 := strings.Index(reportLink, "id=")
+	if strnum1 > 0 {
+		sliceId := strings.Split(reportLink, "id=")
+		if len(sliceId) > 1 {
+			reportLink = sliceId[1]
+			sliceMd5Id := strings.Split(reportLink, "&")
+			artMd5 = sliceMd5Id[0]
+		}
+		if artMd5 != "" {
+			detail, errArt := models.GetArticleDetailByIdMd5(artMd5)
+			if errArt != nil && errArt.Error() != utils.ErrNoRow() {
+				err = errArt
+				return
+			}
+			if detail != nil {
+				articleId = detail.ArticleId
+			}
+		}
+	}
+	return
+}