outside_report.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @Author gmy 2024/9/19 14:53:00
  2. package models
  3. import (
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type OutsideReport struct {
  7. OutsideReportId int `orm:"column(outside_report_id);pk" description:"外部报告ID"`
  8. Source int `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
  9. Title string `orm:"column(title)" description:"报告标题"`
  10. Abstract string `orm:"column(abstract)" description:"摘要"`
  11. ClassifyId int `orm:"column(classify_id)" description:"所属分类id"`
  12. ClassifyName string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"`
  13. Content string `orm:"column(content)" description:"报告富文本内容"`
  14. SysUserId int `orm:"column(sys_user_id)" description:"创建人id"`
  15. SysUserName string `orm:"column(sys_user_name)" description:"创建人姓名"`
  16. EmailMessageUid int `orm:"column(email_message_uid)" description:"该邮件在邮箱中的唯一id"`
  17. ReportUpdateTime string `orm:"column(report_update_time)" description:"报告更新时间,如果来源于邮件,那么取邮件的收件时间"`
  18. ModifyTime string `orm:"column(modify_time)" description:"最近一次修改时间"`
  19. CreateTime string `orm:"column(create_time)" description:"创建时间"`
  20. ReportCode string `orm:"column(report_code)" description:"报告唯一编码"`
  21. }
  22. type OutsideReportBO struct {
  23. OutsideReportId int `orm:"column(outside_report_id);pk" description:"外部报告ID"`
  24. Source int `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
  25. Title string `orm:"column(title)" description:"报告标题"`
  26. Abstract string `orm:"column(abstract)" description:"摘要"`
  27. ClassifyId int `orm:"column(classify_id)" description:"所属分类id"`
  28. ClassifyName string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"`
  29. Content string `orm:"column(content)" description:"报告富文本内容"`
  30. SysUserId int `orm:"column(sys_user_id)" description:"创建人id"`
  31. SysUserName string `orm:"column(sys_user_name)" description:"创建人姓名"`
  32. ReportCode string `orm:"column(report_code)" description:"报告唯一编码"`
  33. AttachmentList []*OutsideReportAttachment
  34. }
  35. type OutsideReportResp struct {
  36. OutsideReportBO *OutsideReportBO `description:"报告"`
  37. Disclaimer string `description:"免责声明"`
  38. H5ShareName string `description:"研报分享抬头"`
  39. H5ReportShareImg string `description:"研报分享图片"`
  40. WatermarkChart string `description:"图表是否需要水印"`
  41. WatermarkReport string `description:"报告是否需要水印"`
  42. Hz int
  43. ReportLogo string `description:"报告logo"`
  44. }
  45. // 在 init 函数中注册模型
  46. func init() {
  47. orm.RegisterModel(new(OutsideReport))
  48. }
  49. // GetOutsideReportListByConditionCount 根据条件查询列表条数
  50. func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) {
  51. o := orm.NewOrm()
  52. sql := `select count(distinct t1.outside_report_id) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id where 1 = 1 `
  53. sql += condition
  54. err = o.Raw(sql, pars).QueryRow(&count)
  55. if err != nil {
  56. return 0, err
  57. }
  58. return count, err
  59. }
  60. // GetOutsideReportByReportCode 根据Code获取报告
  61. func GetOutsideReportByReportCode(reportCode string) (outsideReport *OutsideReport, err error) {
  62. o := orm.NewOrm()
  63. sql := `SELECT * FROM outside_report WHERE report_code=?`
  64. err = o.Raw(sql, reportCode).QueryRow(&outsideReport)
  65. return outsideReport, err
  66. }