outside_report.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // @Author gmy 2024/9/19 14:53:00
  2. package document_manage_model
  3. import (
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. )
  7. type OutsideReport struct {
  8. OutsideReportId int `orm:"column(outside_report_id);pk" description:"外部报告ID"`
  9. Source int `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
  10. Title string `orm:"column(title)" description:"报告标题"`
  11. Abstract string `orm:"column(abstract)" description:"摘要"`
  12. ClassifyId int `orm:"column(classify_id)" description:"所属分类id"`
  13. ClassifyName string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"`
  14. Content string `orm:"column(content)" description:"报告富文本内容"`
  15. SysUserId int `orm:"column(sys_user_id)" description:"创建人id"`
  16. SysUserName string `orm:"column(sys_user_name)" description:"创建人姓名"`
  17. EmailMessageUid int `orm:"column(email_message_uid)" description:"该邮件在邮箱中的唯一id"`
  18. ReportUpdateTime string `orm:"column(report_update_time)" description:"报告更新时间,如果来源于邮件,那么取邮件的收件时间"`
  19. ModifyTime string `orm:"column(modify_time)" description:"最近一次修改时间"`
  20. CreateTime string `orm:"column(create_time)" description:"创建时间"`
  21. }
  22. type OutsideReportPage struct {
  23. List []OutsideReport `description:"报告列表"`
  24. Paging *paging.PagingItem `description:"分页数据"`
  25. }
  26. type OutsideReportBO struct {
  27. OutsideReportId int `orm:"column(outside_report_id);pk" description:"外部报告ID"`
  28. Source int `orm:"column(source)" description:"来源,1:ETA系统录入;2:API接口录入;3:邮件监听录入"`
  29. Title string `orm:"column(title)" description:"报告标题"`
  30. Abstract string `orm:"column(abstract)" description:"摘要"`
  31. ClassifyId int `orm:"column(classify_id)" description:"所属分类id"`
  32. ClassifyName string `orm:"column(classify_name)" description:"所属分类名称(整个分类链条)"`
  33. Content string `orm:"column(content)" description:"报告富文本内容"`
  34. SysUserId int `orm:"column(sys_user_id)" description:"创建人id"`
  35. SysUserName string `orm:"column(sys_user_name)" description:"创建人姓名"`
  36. AttachmentList []*OutsideReportAttachment
  37. }
  38. // 在 init 函数中注册模型
  39. func init() {
  40. orm.RegisterModel(new(OutsideReport))
  41. }
  42. // GetOutsideReportListByConditionCount 根据条件查询列表条数
  43. func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) {
  44. o := orm.NewOrmUsingDB("rddp")
  45. sql := `select count(1) from outside_report t1 inner join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id where 1 = 1 `
  46. sql += sql + condition
  47. err = o.Raw(sql, pars).QueryRow(&count)
  48. if err != nil {
  49. return 0, err
  50. }
  51. return 0, err
  52. }
  53. // GetOutsideReportListByCondition 根据条件查询列表
  54. func GetOutsideReportListByCondition(condition string, pars []interface{}) (list []OutsideReport, err error) {
  55. o := orm.NewOrmUsingDB("rddp")
  56. sql := `select * from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id where 1 = 1 `
  57. sql += condition
  58. _, err = o.Raw(sql, pars).QueryRows(&list)
  59. if err != nil {
  60. return nil, err
  61. }
  62. return list, err
  63. }
  64. /*// GetOutsideReportListByDocumentTypeCount 根据文档类型查询列表条数
  65. func GetOutsideReportListByDocumentTypeCount(documentType int, condition string, pars []interface{}) (count int, err error) {
  66. o := orm.NewOrmUsingDB("rddp")
  67. var sql string
  68. if documentType == 1 {
  69. sql = `select count(t1.OutsideReportId) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id where 1 = 1 `
  70. } else if documentType == 2 {
  71. sql = `select count(t1.OutsideReportId) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id left join user_collect_classify t3 on t1.classify_id = t3.classify_id where 1 = 1 `
  72. }
  73. sql += sql + condition
  74. err = o.Raw(sql, pars).QueryRow(&count)
  75. if err != nil {
  76. return 0, err
  77. }
  78. return 0, err
  79. }
  80. // GetOutsideReportListByDocumentType 根据文档类型查询列表
  81. func GetOutsideReportListByDocumentType(documentType int, condition string, pars []interface{}) (list []OutsideReport, err error) {
  82. o := orm.NewOrmUsingDB("rddp")
  83. var sql string
  84. if documentType == 1 {
  85. sql = `select t1.* from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id where 1 = 1 `
  86. } else if documentType == 2 {
  87. sql = `select t1.* from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id left join user_collect_classify t3 on t1.classify_id = t3.classify_id where 1 = 1 `
  88. }
  89. sql += condition
  90. _, err = o.Raw(sql, pars).QueryRows(&list)
  91. if err != nil {
  92. return nil, err
  93. }
  94. return list, err
  95. }*/
  96. // SaveOutsideReport 保存报告
  97. func SaveOutsideReport(outsideReport OutsideReport) (id int64, err error) {
  98. o := orm.NewOrmUsingDB("rddp")
  99. id, err = o.Insert(&outsideReport)
  100. return
  101. }
  102. // GetOutsideReportById 根据ID获取报告
  103. func GetOutsideReportById(id int) (outsideReport *OutsideReport, err error) {
  104. o := orm.NewOrmUsingDB("rddp")
  105. err = o.QueryTable("outside_report").Filter("outside_report_id", id).One(&outsideReport)
  106. return
  107. }
  108. // UpdateOutsideReport 更新报告
  109. func UpdateOutsideReport(outsideReport *OutsideReport) (err error) {
  110. o := orm.NewOrmUsingDB("rddp")
  111. _, err = o.Update(&outsideReport)
  112. return
  113. }
  114. // DeleteOutsideReport 删除报告
  115. func DeleteOutsideReport(id int) (err error) {
  116. o := orm.NewOrmUsingDB("rddp")
  117. _, err = o.QueryTable("outside_report").Filter("outside_report_id", id).Delete()
  118. return
  119. }