package services import ( "eta/eta_hub/models" "eta/eta_hub/utils" "fmt" "html" "strconv" ) // UpdateEnglishReportEs 更新英文报告/章节Es func UpdateEnglishReportEs(reportId int, publishState int) (err error) { if reportId <= 0 { return } reportOb := new(models.EnglishReport) reportInfo, err := reportOb.GetItemById(reportId) if err != nil { return } // 新增报告ES esReport := &models.ElasticEnglishReportDetail{ Id: strconv.Itoa(reportInfo.Id), ReportId: reportInfo.Id, Title: reportInfo.Title, Abstract: reportInfo.Abstract, BodyContent: utils.TrimHtml(html.UnescapeString(reportInfo.Content)), PublishTime: utils.TimeTransferString(utils.FormatDateTime, reportInfo.PublishTime), CreateTime: utils.TimeTransferString(utils.FormatDateTime, reportInfo.CreateTime), ReportCode: reportInfo.ReportCode, PublishState: publishState, Author: reportInfo.Author, Frequency: reportInfo.Frequency, ClassifyIdFirst: reportInfo.ClassifyIdFirst, ClassifyNameFirst: reportInfo.ClassifyNameFirst, ClassifyIdSecond: reportInfo.ClassifyIdSecond, ClassifyNameSecond: reportInfo.ClassifyNameSecond, StageStr: strconv.Itoa(reportInfo.Stage), Overview: utils.TrimHtml(html.UnescapeString(reportInfo.Overview)), ContentSub: utils.TrimHtml(html.UnescapeString(reportInfo.ContentSub)), } docId := fmt.Sprintf("%d", reportInfo.Id) if err = EsAddOrEditEnglishReport(utils.EsEnglishReportIndexName, docId, esReport); err != nil { return } return }