english_report.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package services
  2. import (
  3. "eta/eta_hub/models"
  4. "eta/eta_hub/utils"
  5. "fmt"
  6. "html"
  7. "strconv"
  8. )
  9. // UpdateEnglishReportEs 更新英文报告/章节Es
  10. func UpdateEnglishReportEs(reportId int, publishState int) (err error) {
  11. if reportId <= 0 {
  12. return
  13. }
  14. reportOb := new(models.EnglishReport)
  15. reportInfo, err := reportOb.GetItemById(reportId)
  16. if err != nil {
  17. return
  18. }
  19. // 新增报告ES
  20. esReport := &models.ElasticEnglishReportDetail{
  21. Id: strconv.Itoa(reportInfo.Id),
  22. ReportId: reportInfo.Id,
  23. Title: reportInfo.Title,
  24. Abstract: reportInfo.Abstract,
  25. BodyContent: utils.TrimHtml(html.UnescapeString(reportInfo.Content)),
  26. PublishTime: utils.TimeTransferString(utils.FormatDateTime, reportInfo.PublishTime),
  27. CreateTime: utils.TimeTransferString(utils.FormatDateTime, reportInfo.CreateTime),
  28. ReportCode: reportInfo.ReportCode,
  29. PublishState: publishState,
  30. Author: reportInfo.Author,
  31. Frequency: reportInfo.Frequency,
  32. ClassifyIdFirst: reportInfo.ClassifyIdFirst,
  33. ClassifyNameFirst: reportInfo.ClassifyNameFirst,
  34. ClassifyIdSecond: reportInfo.ClassifyIdSecond,
  35. ClassifyNameSecond: reportInfo.ClassifyNameSecond,
  36. StageStr: strconv.Itoa(reportInfo.Stage),
  37. Overview: utils.TrimHtml(html.UnescapeString(reportInfo.Overview)),
  38. ContentSub: utils.TrimHtml(html.UnescapeString(reportInfo.ContentSub)),
  39. }
  40. docId := fmt.Sprintf("%d", reportInfo.Id)
  41. if err = EsAddOrEditEnglishReport(utils.EsEnglishReportIndexName, docId, esReport); err != nil {
  42. return
  43. }
  44. return
  45. }