|
@@ -11,6 +11,7 @@ import (
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
"strconv"
|
|
"strconv"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -86,8 +87,18 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
}
|
|
}
|
|
classifySecond, ok := classifyMap[articleResult.Series.Name]
|
|
classifySecond, ok := classifyMap[articleResult.Series.Name]
|
|
if !ok {
|
|
if !ok {
|
|
- err = fmt.Errorf("二级分类不存在")
|
|
|
|
- return err
|
|
|
|
|
|
+ // 新增二级分类
|
|
|
|
+ err, _, _ = AddReportClassify(articleResult.Series.Name, classifyFirst.Id, []int{})
|
|
|
|
+ if err != nil {
|
|
|
|
+ err = fmt.Errorf("添加二级分类失败, Err: %s", err.Error())
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ item, err := models.GetClassifyByName(articleResult.Series.Name, classifyFirst.Id)
|
|
|
|
+ if err != nil {
|
|
|
|
+ err = fmt.Errorf("添加二级分类失败, Err: %s", err.Error())
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ classifySecond = item
|
|
}
|
|
}
|
|
// 判断分类的层级关系是否合理
|
|
// 判断分类的层级关系是否合理
|
|
if classifyFirst.Id != classifySecond.ParentId {
|
|
if classifyFirst.Id != classifySecond.ParentId {
|
|
@@ -125,14 +136,18 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
// 报告状态为未发布,则更新报告
|
|
// 报告状态为未发布,则更新报告
|
|
state = models.ReportStateUnpublished
|
|
state = models.ReportStateUnpublished
|
|
reportInfo.PublishTime = articleResult.PublishDate
|
|
reportInfo.PublishTime = articleResult.PublishDate
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ // 过滤Abstracthtml标签,把<p>标签去掉
|
|
|
|
+ abstract := strings.ReplaceAll(articleResult.Content.Abstract, "<p>", "")
|
|
|
|
+ abstract = strings.ReplaceAll(abstract, "</p>", "")
|
|
|
|
|
|
reportInfo.ClassifyIdFirst = classifyFirst.Id
|
|
reportInfo.ClassifyIdFirst = classifyFirst.Id
|
|
reportInfo.ClassifyNameFirst = articleResult.Industry.Name
|
|
reportInfo.ClassifyNameFirst = articleResult.Industry.Name
|
|
reportInfo.ClassifyIdSecond = classifySecond.Id
|
|
reportInfo.ClassifyIdSecond = classifySecond.Id
|
|
reportInfo.ClassifyNameSecond = articleResult.Series.Name
|
|
reportInfo.ClassifyNameSecond = articleResult.Series.Name
|
|
reportInfo.Title = articleResult.Title
|
|
reportInfo.Title = articleResult.Title
|
|
- reportInfo.Abstract = articleResult.Content.Abstract
|
|
|
|
|
|
+ reportInfo.Abstract = abstract
|
|
reportInfo.Author = articleResult.Author.Name
|
|
reportInfo.Author = articleResult.Author.Name
|
|
reportInfo.Frequency = articleResult.Frequency
|
|
reportInfo.Frequency = articleResult.Frequency
|
|
reportInfo.State = state
|
|
reportInfo.State = state
|
|
@@ -140,8 +155,22 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
reportInfo.ContentSub = html.EscapeString(contentSub)
|
|
reportInfo.ContentSub = html.EscapeString(contentSub)
|
|
updateTime, _ := time.ParseInLocation(utils.FormatDate, articleResult.UpdateDate, time.Local)
|
|
updateTime, _ := time.ParseInLocation(utils.FormatDate, articleResult.UpdateDate, time.Local)
|
|
reportInfo.ModifyTime = updateTime
|
|
reportInfo.ModifyTime = updateTime
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ // 报告更新
|
|
|
|
+ updateCols := []string{"ClassifyIdFirst","ClassifyNameFirst","ClassifyIdSecond","ClassifyNameSecond","Title","Abstract","Author","Frequency","State","Content","ContentSub","ModifyTime","PublishTime"}
|
|
|
|
+ err = reportInfo.UpdateReport(updateCols)
|
|
|
|
+ if err != nil {
|
|
|
|
+ err = fmt.Errorf("更新报告失败, Err: %s", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
go UpdateReportEs(reportInfo.Id, state)
|
|
go UpdateReportEs(reportInfo.Id, state)
|
|
|
|
+ if state == models.ReportStatePublished {
|
|
|
|
+ // 报告权限处理
|
|
|
|
+ go handleReportPermission(int64(reportInfo.Id), reportInfo.ClassifyIdSecond)
|
|
|
|
+ }else {
|
|
|
|
+ // 重置小程序详情页海报
|
|
|
|
+ _ = ResetMiniProgramReportDetailCover(reportInfo.Id)
|
|
|
|
+ }
|
|
|
|
|
|
}else if reportInfo.Id == 0 {
|
|
}else if reportInfo.Id == 0 {
|
|
// 报告不存在,创建报告
|
|
// 报告不存在,创建报告
|
|
@@ -167,6 +196,9 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
// 是否公开发布,1:是,2:否
|
|
// 是否公开发布,1:是,2:否
|
|
isPublicPublish := 1
|
|
isPublicPublish := 1
|
|
|
|
|
|
|
|
+ abstract := strings.ReplaceAll(articleResult.Content.Abstract, "<p>", "")
|
|
|
|
+ abstract = strings.ReplaceAll(abstract, "</p>", "")
|
|
|
|
+
|
|
item := new(models.Report)
|
|
item := new(models.Report)
|
|
item.AddType = 1
|
|
item.AddType = 1
|
|
item.ReportVersion = 2
|
|
item.ReportVersion = 2
|
|
@@ -175,7 +207,7 @@ func HandleInsertRaiReport(raiReportId int) (err error) {
|
|
item.ClassifyIdSecond = classifySecond.Id
|
|
item.ClassifyIdSecond = classifySecond.Id
|
|
item.ClassifyNameSecond = articleResult.Series.Name
|
|
item.ClassifyNameSecond = articleResult.Series.Name
|
|
item.Title = articleResult.Title
|
|
item.Title = articleResult.Title
|
|
- item.Abstract = articleResult.Content.Abstract
|
|
|
|
|
|
+ item.Abstract = abstract
|
|
item.Author = articleResult.Author.Name
|
|
item.Author = articleResult.Author.Name
|
|
item.Frequency = articleResult.Frequency
|
|
item.Frequency = articleResult.Frequency
|
|
item.State = state
|
|
item.State = state
|