فهرست منبع

策略平台文章同步方式修改处理

xingzai 2 سال پیش
والد
کامیت
13aebcf048
2فایلهای تغییر یافته به همراه21 افزوده شده و 4 حذف شده
  1. 12 3
      models/article.go
  2. 9 1
      services/article.go

+ 12 - 3
models/article.go

@@ -43,6 +43,7 @@ type CygxArticle struct {
 	VideoPlaySeconds string `description:"音频播放时长"`
 	Stock            string `description:"个股标签"`
 	FieldName        string `description:"产业标签"`
+	Annotation       string `description:"核心观点"`
 }
 
 type CygxArticleEs struct {
@@ -522,6 +523,7 @@ type ArticleResultApidate struct {
 	Type          ArticleResultApiType     `json:"type"`
 	Stock         []string                 `json:"stock"`
 	Field         ArticleField             `json:"field"`
+	Corpus        Corpus                   `json:"corpus"`
 }
 
 type ArticleField struct {
@@ -531,13 +533,20 @@ type ArticleField struct {
 	IndustryId  int    `json:"industry_id"`
 }
 
+type Corpus struct {
+	Id        int    `json:"id"`
+	ArticleId int    `json:"article_id"`
+	Corpus    string `json:"corpus"`
+}
+
 type ArticleSeries struct {
 	Name string `json:"name"`
 }
 type ArticleResultApiContent struct {
-	ArticleId int    `json:"id"`
-	Body      string `json:"body"`
-	Abstract  string `json:"abstract"`
+	ArticleId  int    `json:"id"`
+	Body       string `json:"body"`
+	Abstract   string `json:"abstract"`
+	Annotation string `json:"annotation"`
 }
 
 type ArticleResultApiAuthor struct {

+ 9 - 1
services/article.go

@@ -637,6 +637,11 @@ func GetArticleListByApi(cont context.Context) (err error) {
 	return
 }
 
+//func init() {
+//
+//	HandleArticleListByApi(7214)
+//}
+
 //处理同步过来的文章
 func HandleArticleListByApi(artcleId int) (err error) {
 	defer func() {
@@ -718,8 +723,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		item.CreateDate = articleResult.CreateDate
 		item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
 		item.PublishStatus = 1
-		item.Body = articleResult.Content.Body
+		item.Body = articleResult.Corpus.Corpus
 		item.Abstract = articleResult.Content.Abstract
+		item.Annotation = articleResult.Content.Annotation
 		item.CategoryName = articleResult.Industry.Name
 		item.CategoryId = exitMap[articleResult.SeriesId]
 		item.SubCategoryName = articleResult.Series.Name
@@ -885,6 +891,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			updateParams["FileLink"] = v.File
 			updateParams["Stock"] = v.Stock
 			updateParams["FieldName"] = v.FieldName
+			updateParams["Annotation"] = v.Annotation
 			whereParam := map[string]interface{}{"article_id": v.ArticleId}
 			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
 			if err != nil {
@@ -923,6 +930,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			item.MatchTypeName = matchTypeName
 			item.Stock = v.Stock
 			item.FieldName = v.FieldName
+			item.Annotation = v.Annotation
 			newId, err := models.AddCygxArticles(item)
 			if err != nil {
 				fmt.Println("AddCygxArticle Err:", err.Error())