report.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package models
  2. import (
  3. "rdluck_tools/orm"
  4. "time"
  5. )
  6. type Report struct {
  7. Id int `description:"报告Id"`
  8. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  9. ClassifyIdFirst int `description:"一级分类id"`
  10. ClassifyNameFirst string `description:"一级分类名称"`
  11. ClassifyIdSecond int `description:"二级分类id"`
  12. ClassifyNameSecond string `description:"二级分类名称"`
  13. Title string `description:"标题"`
  14. Abstract string `description:"摘要"`
  15. Author string `description:"作者"`
  16. Frequency string `description:"频度"`
  17. CreateTime string `description:"创建时间"`
  18. ModifyTime time.Time `description:"修改时间"`
  19. State int `description:"1:未发布,2:已发布"`
  20. PublishTime string `description:"发布时间"`
  21. Stage int `description:"期数"`
  22. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  23. Content string `description:"内容"`
  24. VideoUrl string `description:"音频文件URL"`
  25. VideoName string `description:"音频文件名称"`
  26. VideoPlaySeconds string `description:"音频播放时长"`
  27. ContentSub string `description:"内容前两个章节"`
  28. }
  29. type ReportList struct {
  30. Id int `description:"报告Id"`
  31. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  32. ClassifyIdFirst int `description:"一级分类id"`
  33. ClassifyNameFirst string `description:"一级分类名称"`
  34. ClassifyIdSecond int `description:"二级分类id"`
  35. ClassifyNameSecond string `description:"二级分类名称"`
  36. Title string `description:"标题"`
  37. Abstract string `description:"摘要"`
  38. Author string `description:"作者"`
  39. Frequency string `description:"频度"`
  40. CreateTime string `description:"创建时间"`
  41. ModifyTime time.Time `description:"修改时间"`
  42. State int `description:"1:未发布,2:已发布"`
  43. PublishTime string `description:"发布时间"`
  44. Stage int `description:"期数"`
  45. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  46. Content string `description:"内容"`
  47. VideoUrl string `description:"音频文件URL"`
  48. VideoName string `description:"音频文件名称"`
  49. VideoPlaySeconds string `description:"音频播放时长"`
  50. ContentSub string `description:"内容前两个章节"`
  51. HasPermission int `description:"是否拥有报告权限,1:拥有,0:没有"`
  52. }
  53. type ReportListResp struct {
  54. List []*ReportList
  55. Paging *PagingItem `description:"分页数据"`
  56. }
  57. func GetReportListCount(classifyId int) (count int, err error) {
  58. o := orm.NewOrm()
  59. o.Using("rddp")
  60. sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 AND classify_id_second=? `
  61. err = o.Raw(sql, classifyId).QueryRow(&count)
  62. return
  63. }
  64. func GetReportList(classifyId, startSize, pageSize int) (items []*ReportList, err error) {
  65. o := orm.NewOrm()
  66. o.Using("rddp")
  67. sql := ` SELECT * FROM report WHERE state=2 AND classify_id_second=? ORDER BY publish_time DESC LIMIT ?,? `
  68. _, err = o.Raw(sql, classifyId, startSize, pageSize).QueryRows(&items)
  69. return
  70. }
  71. func GetReportPermission(userId int, classifyNameSecond string) (count int, err error) {
  72. o := orm.NewOrm()
  73. sql := ` SELECT COUNT(1) AS count
  74. FROM company_report_permission AS crp
  75. INNER JOIN chart_permission_chapter_mapping AS cpcm ON crp.chart_permission_id = cpcm.chart_permission_id
  76. INNER JOIN chart_permission_search_key_word_mapping AS cskwm ON cskwm.chart_permission_id=crp.chart_permission_id
  77. INNER JOIN wx_user wu ON wu.company_id = crp.company_id
  78. WHERE wu.user_id = ?
  79. AND cpcm.research_type = 'rddp'
  80. AND cskwm.from='rddp'
  81. AND cskwm.key_word=? `
  82. err = o.Raw(sql, userId, classifyNameSecond).QueryRow(&count)
  83. return
  84. }
  85. func GetReportById(reportId int) (item *Report, err error) {
  86. o := orm.NewOrm()
  87. o.Using("rddp")
  88. sql := `SELECT * FROM report WHERE id=?`
  89. err = o.Raw(sql, reportId).QueryRow(&item)
  90. return
  91. }
  92. type ReportVarietyList struct {
  93. ReportChapterTypeId int
  94. }
  95. func GetReportVarietyListByUserIdExt(userId int, reportType string) (list []*ReportVarietyList, err error) {
  96. o := orm.NewOrm()
  97. sql := `SELECT cpcm.report_chapter_type_id
  98. FROM company_report_permission crp
  99. INNER JOIN chart_permission_chapter_mapping cpcm ON crp.chart_permission_id = cpcm.chart_permission_id
  100. INNER JOIN wx_user wu ON wu.company_id = crp.company_id
  101. WHERE wu.user_id = ?
  102. AND cpcm.research_type = ?
  103. GROUP BY cpcm.report_chapter_type_id`
  104. _, err = o.Raw(sql, userId, reportType).QueryRows(&list)
  105. return
  106. }
  107. type ReportDetailResp struct {
  108. Report *Report `description:"报告"`
  109. Status int `description:"状态:0:正常展示,1:报告不存在,2:无权限"`
  110. Msg string `description:"提示信息"`
  111. }