Browse Source

核心观点字段解析

xingzai 2 years ago
parent
commit
9ed2e823ba
4 changed files with 28 additions and 7 deletions
  1. 9 1
      controllers/report.go
  2. 1 1
      models/wx_user.go
  3. 14 4
      services/article.go
  4. 4 1
      utils/constants.go

+ 9 - 1
controllers/report.go

@@ -506,6 +506,7 @@ func (this *ReportController) List() {
 		list[i].Body, _ = services.GetReportContentTextSub(item.Body)
 		//list[i].Abstract = html.UnescapeString(item.Abstract)
 		list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
+		list[i].Annotation = services.GetAnnotationTextSub(item.Annotation)
 	}
 
 	for k, v := range list {
@@ -516,7 +517,14 @@ func (this *ReportController) List() {
 			list[k].IsHaveVideo = true
 		}
 		list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+
+		if mapCategoryUrl[v.CategoryId] == "" {
+			if detail.ChartPermissionId == utils.YI_YAO_ID {
+				list[k].ImgUrlPc = utils.YI_YAO_QI_TA
+			}
+		}
 	}
+
 	resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 	resp.List = list
 	resp.Paging = page
@@ -2322,7 +2330,7 @@ func (this *ReportController) SearchReport() {
 	var condition string
 	var sqlGroup string
 	//匹配报告标题、
-	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
+	condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
 	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
 	//对应产业名称、标的名称。
 	//OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )

+ 1 - 1
models/wx_user.go

@@ -520,7 +520,7 @@ func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInterac
 			( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.user_id = u.user_id  ) AS chart_count_num,
 			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = u.user_id  ) AS industry_fllow_num,
 			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = u.user_id   ) AS department_follow_num,
-			( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = u.user_id  ) AS key_word_num,
+			( SELECT COUNT( 1 ) FROM cygx_search_key_word_log AS h WHERE h.user_id = u.user_id  ) AS key_word_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  
 					 AND t.activity_type = 1  AND h.do_fail_type = 0 ) AS on_line_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.mobile = u.mobile  

+ 14 - 4
services/article.go

@@ -56,6 +56,12 @@ func GetReportContentTextSub(content string) (contentSub string, err error) {
 	return
 }
 
+func GetAnnotationTextSub(content string) (contentSub string) {
+	contentSub = strings.Replace(content, "<p class=\"ql-align-justify\">", "&nbsp;", -1)
+	contentSub = strings.Replace(contentSub, "</p>", "", -1)
+	return
+}
+
 func GetReportContentTextSubNew(content string) (contentSub string, err error) {
 	content = html.UnescapeString(content)
 	doc, errdoc := goquery.NewDocumentFromReader(strings.NewReader(content))
@@ -672,8 +678,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 }
 
 //func init() {
-//
-//	HandleArticleListByApi(7214)
+//	HandleArticleListByApi(7164)
 //}
 
 //处理同步过来的文章
@@ -764,7 +769,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		item.CreateDate = articleResult.CreateDate
 		item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
 		item.PublishStatus = 1
-		item.Body = articleResult.Corpus.Corpus
+		item.Body = articleResult.Content.Body
 		item.Abstract = articleResult.Content.Abstract
 		item.Annotation = articleResult.Content.Annotation
 		item.CategoryName = articleResult.Industry.Name
@@ -989,6 +994,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 				var keyword4 string
 				sliceSubjects := strings.Split(v.Stock, "/")
 				mapManagementForSubject := make(map[string]string)
+				mapIndustrialId := make(map[int]int)
 				if len(sliceSubjects) > 0 {
 					for _, vSubject := range sliceSubjects {
 						sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
@@ -1014,10 +1020,14 @@ func HandleArticleListByApi(artcleId int) (err error) {
 						subjectStr = "【" + subjectStr + "】"
 						if len(listIndustrial) > 0 {
 							for _, vIndustrial := range listIndustrial {
-								industrialManagementIdStr += strconv.Itoa(vIndustrial.IndustrialManagementId) + ","
+								if _, ok := mapIndustrialId[vIndustrial.IndustrialManagementId]; !ok {
+									industrialManagementIdStr += strconv.Itoa(vIndustrial.IndustrialManagementId) + ","
+								}
+								mapIndustrialId[vIndustrial.IndustrialManagementId] = vIndustrial.IndustrialManagementId
 								industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
 								mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
 							}
+
 							industrialManagementIdStr = strings.TrimRight(industrialManagementIdStr, ",")
 							industrialSubjectIdStr = strings.TrimRight(industrialSubjectIdStr, ",")
 							if industrialManagementIdStr != "" {

+ 4 - 1
utils/constants.go

@@ -124,4 +124,7 @@ const (
 	COMPANY_PRODUCT_FICC_NAME = "ficc"
 	COMPANY_PRODUCT_RAI_ID    = 2
 	COMPANY_PRODUCT_RAI_NAME  = "权益"
-)
+)
+const (
+	YI_YAO_QI_TA = "https://hzstatic.hzinsights.com/static/temp/20220922202209/20220922/2OQMBFplQE1R3bX1y3obX7JSwSuA.png"
+)