Browse Source

策略平台领域字段添加同步

xingzai 2 years ago
parent
commit
ed4f84404e
3 changed files with 18 additions and 13 deletions
  1. 1 0
      models/article.go
  2. 1 0
      models/tactics.go
  3. 16 13
      services/article.go

+ 1 - 0
models/article.go

@@ -46,6 +46,7 @@ type CygxArticle struct {
 	Annotation       string `description:"核心观点"`
 	TypeName         string `description:"策略平台报告类型"`
 	ModifyTimeByCl   string `description:"策略平台报告更新时间"`
+	CeLueFieldId     int    `description:"策略平台领域ID"`
 }
 
 type CygxArticleEs struct {

+ 1 - 0
models/tactics.go

@@ -83,6 +83,7 @@ type Tactics2 struct {
 	File            string    `description:"Pdf下载链接"`
 	TypeName        string    `description:"策略平台报告类型"`
 	UpdateDate      string    `description:"策略平台报告更新时间"`
+	CeLueFieldId    int       `description:"策略平台领域ID"`
 }
 
 func GetTacticsList2(endDate string) (list []*Tactics2, err error) {

+ 16 - 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 {
@@ -800,6 +800,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		item.FieldName = articleResult.Field.Name
 		item.TypeName = articleResult.Type.Name
 		item.UpdateDate = articleResult.UpdateDate
+		item.CeLueFieldId = articleResult.Field.Id
 		list = append(list, item)
 		itemAuthor.ArticleId = articleResult.ArticleId
 		itemAuthor.Name = articleResult.Author.Name
@@ -985,6 +986,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			updateParams["Annotation"] = v.Annotation
 			updateParams["TypeName"] = v.TypeName
 			updateParams["ModifyTimeByCl"] = v.UpdateDate
+			updateParams["CeLueFieldId"] = v.CeLueFieldId
 			whereParam := map[string]interface{}{"article_id": v.ArticleId}
 			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
 			if err != nil {
@@ -1027,6 +1029,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			item.Annotation = v.Annotation
 			item.TypeName = v.TypeName
 			item.ModifyTimeByCl = v.UpdateDate
+			item.CeLueFieldId = v.CeLueFieldId
 			newId, err := models.AddCygxArticles(item)
 			if err != nil {
 				fmt.Println("AddCygxArticle Err:", err.Error())
@@ -1161,7 +1164,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 +1594,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 +1624,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 +1673,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 +1811,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 +1884,7 @@ func ArticleAnnotation(item *models.HomeArticle) (annotation string) {
 	return
 }
 
-//解析研选内容中的核心观点
+// 解析研选内容中的核心观点
 func YxArticleAnnotation(article *models.HomeArticle) (annotation string) {
 	//如果不规范,就获取内容主体
 	if strings.Count(article.Body, "<hr") == 0 {