report.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. IsShowNewLabel int `description:"是否显示新标签"`
  29. IsCurrentDate int `description:"是否当前日期"`
  30. ClassifyName string `description:"分类名称"`
  31. }
  32. type ReportList struct {
  33. Id int `description:"报告Id"`
  34. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  35. ClassifyIdFirst int `description:"一级分类id"`
  36. ClassifyNameFirst string `description:"一级分类名称"`
  37. ClassifyIdSecond int `description:"二级分类id"`
  38. ClassifyNameSecond string `description:"二级分类名称"`
  39. Title string `description:"标题"`
  40. Abstract string `description:"摘要"`
  41. Author string `description:"作者"`
  42. Frequency string `description:"频度"`
  43. CreateTime string `description:"创建时间"`
  44. ModifyTime time.Time `description:"修改时间"`
  45. State int `description:"1:未发布,2:已发布"`
  46. PublishTime string `description:"发布时间"`
  47. Stage int `description:"期数"`
  48. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  49. Content string `description:"内容"`
  50. VideoUrl string `description:"音频文件URL"`
  51. VideoName string `description:"音频文件名称"`
  52. VideoPlaySeconds string `description:"音频播放时长"`
  53. ContentSub string `description:"内容前两个章节"`
  54. HasPermission int `description:"是否拥有报告权限,1:拥有,0:没有"`
  55. }
  56. type ReportListResp struct {
  57. List []*ReportList
  58. Paging *PagingItem `description:"分页数据"`
  59. }
  60. func GetReportListCount(classifyId int) (count int, err error) {
  61. o := orm.NewOrm()
  62. o.Using("rddp")
  63. sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 AND classify_id_second=? `
  64. err = o.Raw(sql, classifyId).QueryRow(&count)
  65. return
  66. }
  67. func GetReportList(classifyId, startSize, pageSize int) (items []*ReportList, err error) {
  68. o := orm.NewOrm()
  69. o.Using("rddp")
  70. sql := ` SELECT * FROM report WHERE state=2 AND classify_id_second=? ORDER BY publish_time DESC LIMIT ?,? `
  71. _, err = o.Raw(sql, classifyId, startSize, pageSize).QueryRows(&items)
  72. return
  73. }
  74. func GetReportPermission(userId int, classifyNameSecond string) (count int, err error) {
  75. o := orm.NewOrm()
  76. sql := ` SELECT COUNT(1) AS count
  77. FROM company_report_permission AS crp
  78. INNER JOIN chart_permission_chapter_mapping AS cpcm ON crp.chart_permission_id = cpcm.chart_permission_id
  79. INNER JOIN chart_permission_search_key_word_mapping AS cskwm ON cskwm.chart_permission_id=crp.chart_permission_id
  80. INNER JOIN wx_user wu ON wu.company_id = crp.company_id
  81. WHERE wu.user_id = ?
  82. AND cpcm.research_type = 'rddp'
  83. AND cskwm.from='rddp'
  84. AND cskwm.key_word=? `
  85. err = o.Raw(sql, userId, classifyNameSecond).QueryRow(&count)
  86. return
  87. }
  88. func GetReportById(reportId int) (item *Report, err error) {
  89. o := orm.NewOrm()
  90. o.Using("rddp")
  91. sql := `SELECT * FROM report WHERE id=?`
  92. err = o.Raw(sql, reportId).QueryRow(&item)
  93. return
  94. }
  95. type ReportVarietyList struct {
  96. ReportChapterTypeId int
  97. }
  98. func GetReportVarietyListByUserIdExt(userId int, reportType string) (list []*ReportVarietyList, err error) {
  99. o := orm.NewOrm()
  100. sql := `SELECT cpcm.report_chapter_type_id
  101. FROM company_report_permission crp
  102. INNER JOIN chart_permission_chapter_mapping cpcm ON crp.chart_permission_id = cpcm.chart_permission_id
  103. INNER JOIN wx_user wu ON wu.company_id = crp.company_id
  104. WHERE wu.user_id = ?
  105. AND cpcm.research_type = ?
  106. GROUP BY cpcm.report_chapter_type_id`
  107. _, err = o.Raw(sql, userId, reportType).QueryRows(&list)
  108. return
  109. }
  110. type ReportDetailResp struct {
  111. Report *Report `description:"报告"`
  112. RecommendList []*RecommendReport `description:"推荐报告列表"`
  113. Status int `description:"状态:0:正常展示,1:报告不存在,2:无权限"`
  114. Msg string `description:"提示信息"`
  115. }
  116. type ReportRecordReq struct {
  117. ReportId int `description:"报告Id"`
  118. }
  119. type RecommendReport struct {
  120. Id int `description:"报告Id"`
  121. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  122. ClassifyIdFirst int `description:"一级分类id"`
  123. ClassifyNameFirst string `description:"一级分类名称"`
  124. ClassifyIdSecond int `description:"二级分类id"`
  125. ClassifyNameSecond string `description:"二级分类名称"`
  126. Title string `description:"标题"`
  127. Abstract string `description:"摘要"`
  128. Author string `description:"作者"`
  129. Frequency string `description:"频度"`
  130. CreateTime string `description:"创建时间"`
  131. ModifyTime time.Time `description:"修改时间"`
  132. State int `description:"1:未发布,2:已发布"`
  133. PublishTime string `description:"发布时间"`
  134. Stage int `description:"期数"`
  135. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  136. Content string `description:"内容"`
  137. VideoUrl string `description:"音频文件URL"`
  138. VideoName string `description:"音频文件名称"`
  139. VideoPlaySeconds string `description:"音频播放时长"`
  140. ContentSub string `description:"内容前两个章节"`
  141. ClassifyName string `description:"分类名称"`
  142. HasPermission int `description:"报告权限:0:无权限,1:有权限"`
  143. }
  144. func GetRecommendList(reportId int) (items []*RecommendReport, err error) {
  145. o := orm.NewOrm()
  146. o.Using("rddp")
  147. sql := `SELECT * FROM report WHERE id<>? ORDER BY publish_time DESC LIMIT 3`
  148. _, err = o.Raw(sql, reportId).QueryRows(&items)
  149. return
  150. }