report.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/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. VideoSize string `description:"音频文件大小,单位M"`
  28. ContentSub string `description:"内容前两个章节"`
  29. IsShowNewLabel int `description:"是否显示新标签"`
  30. IsCurrentDate int `description:"是否当前日期"`
  31. ClassifyName string `description:"分类名称"`
  32. }
  33. type ReportList struct {
  34. Id int `description:"报告Id"`
  35. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  36. ClassifyIdFirst int `description:"一级分类id"`
  37. ClassifyNameFirst string `description:"一级分类名称"`
  38. ClassifyIdSecond int `description:"二级分类id"`
  39. ClassifyNameSecond string `description:"二级分类名称"`
  40. Title string `description:"标题"`
  41. Abstract string `description:"摘要"`
  42. Author string `description:"作者"`
  43. Frequency string `description:"频度"`
  44. CreateTime string `description:"创建时间"`
  45. ModifyTime time.Time `description:"修改时间"`
  46. State int `description:"1:未发布,2:已发布"`
  47. PublishTime string `description:"发布时间"`
  48. Stage int `description:"期数"`
  49. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  50. Content string `description:"内容"`
  51. VideoUrl string `description:"音频文件URL"`
  52. VideoName string `description:"音频文件名称"`
  53. VideoPlaySeconds string `description:"音频播放时长"`
  54. VideoSize string `description:"音频文件大小,单位M"`
  55. HasPermission int `description:"是否拥有报告权限,1:拥有,0:没有"`
  56. TitleType string `description:"标题类型,FICC或者权益"`
  57. IsCurrentDate int `description:"是否当前日期:1是,0不是"`
  58. ClassifyDetail
  59. }
  60. type ReportListResp struct {
  61. List []*ReportList
  62. Paging *PagingItem `description:"分页数据"`
  63. }
  64. func GetReportListCount(classifyId int) (count int, err error) {
  65. o := orm.NewOrmUsingDB("rddp")
  66. sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 AND classify_id_second=? `
  67. err = o.Raw(sql, classifyId).QueryRow(&count)
  68. return
  69. }
  70. func GetReportList(classifyId, startSize, pageSize int) (items []*ReportList, err error) {
  71. o := orm.NewOrmUsingDB("rddp")
  72. sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
  73. a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
  74. b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size,
  75. CASE WHEN DATE(a.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
  76. FROM report AS a
  77. INNER JOIN classify AS b ON a.classify_id_second=b.id
  78. WHERE a.state=2 AND a.classify_id_second=? ORDER BY a.publish_time DESC LIMIT ?,? `
  79. _, err = o.Raw(sql, classifyId, startSize, pageSize).QueryRows(&items)
  80. return
  81. }
  82. func GetReportPermission(userId int, classifyNameSecond string) (count int, err error) {
  83. o := orm.NewOrm()
  84. sql := ` SELECT COUNT(1) AS count
  85. FROM company_report_permission AS crp
  86. INNER JOIN chart_permission_chapter_mapping AS cpcm ON crp.chart_permission_id = cpcm.chart_permission_id
  87. INNER JOIN chart_permission_search_key_word_mapping AS cskwm ON cskwm.chart_permission_id=crp.chart_permission_id
  88. INNER JOIN wx_user wu ON wu.company_id = crp.company_id
  89. WHERE wu.user_id = ?
  90. AND cpcm.research_type = 'rddp'
  91. AND cskwm.from='rddp'
  92. AND cskwm.key_word=? `
  93. err = o.Raw(sql, userId, classifyNameSecond).QueryRow(&count)
  94. return
  95. }
  96. type ReportDetail struct {
  97. Id int `description:"报告Id"`
  98. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  99. ClassifyIdFirst int `description:"一级分类id"`
  100. ClassifyNameFirst string `description:"一级分类名称"`
  101. ClassifyIdSecond int `description:"二级分类id"`
  102. ClassifyNameSecond string `description:"二级分类名称"`
  103. Title string `description:"标题"`
  104. Abstract string `description:"摘要"`
  105. Author string `description:"作者"`
  106. Frequency string `description:"频度"`
  107. CreateTime string `description:"创建时间"`
  108. ModifyTime string `description:"修改时间"`
  109. State int `description:"1:未发布,2:已发布"`
  110. PublishTime string `description:"发布时间"`
  111. Stage int `description:"期数"`
  112. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  113. Content string `description:"内容"`
  114. VideoUrl string `description:"音频文件URL"`
  115. VideoName string `description:"音频文件名称"`
  116. VideoPlaySeconds string `description:"音频播放时长"`
  117. VideoSize string `description:"音频文件大小,单位M"`
  118. ContentSub string `description:"内容前两个章节"`
  119. IsShowNewLabel int `description:"是否显示新标签"`
  120. IsCurrentDate int `description:"是否当前日期"`
  121. ClassifyName string `description:"分类名称"`
  122. TitleType string `description:"标题类型,FICC或者权益"`
  123. }
  124. func GetReportById(reportId int) (item *ReportDetail, err error) {
  125. o := orm.NewOrmUsingDB("rddp")
  126. sql := `SELECT * FROM report WHERE id=?`
  127. err = o.Raw(sql, reportId).QueryRow(&item)
  128. return
  129. }
  130. type ReportVarietyList struct {
  131. ReportChapterTypeId int
  132. }
  133. func GetReportVarietyListByUserIdExt(userId int, reportType string) (list []*ReportVarietyList, err error) {
  134. o := orm.NewOrm()
  135. sql := `SELECT cpcm.report_chapter_type_id
  136. FROM company_report_permission crp
  137. INNER JOIN chart_permission_chapter_mapping cpcm ON crp.chart_permission_id = cpcm.chart_permission_id
  138. INNER JOIN wx_user wu ON wu.company_id = crp.company_id
  139. WHERE wu.user_id = ?
  140. AND cpcm.research_type = ?
  141. GROUP BY cpcm.report_chapter_type_id`
  142. _, err = o.Raw(sql, userId, reportType).QueryRows(&list)
  143. return
  144. }
  145. type ReportDetailResp struct {
  146. Report *ReportDetail `description:"报告"`
  147. RecommendList []*RecommendReport `description:"推荐报告列表"`
  148. Status int `description:"状态:0:正常展示,1:报告不存在,2:无权限"`
  149. Msg string `description:"提示信息"`
  150. Classify *ClassifyDetail `description:"对应专栏"`
  151. PermissionCheckInfo PermissionCheckInfoResp `description:"权限相关"`
  152. }
  153. // PermissionCheckInfo 权限校验完成后的结果
  154. type PermissionCheckInfoResp struct {
  155. Name string `description:"销售名称"`
  156. Mobile string `description:"销售手机号"`
  157. Type string `description:"校验失败,没有权限,需要让前端处理的类型,枚举值:apply,contact"`
  158. Status string `description:"客户状态"`
  159. HasApply bool `description:"是否有申请过"`
  160. CompanyName string `description:"公司名称"`
  161. RealName string `description:"联系人姓名"`
  162. }
  163. type ReportRecordReq struct {
  164. ReportId int `description:"报告Id"`
  165. }
  166. type RecommendReport struct {
  167. Id int `description:"报告Id"`
  168. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  169. ClassifyIdFirst int `description:"一级分类id"`
  170. ClassifyNameFirst string `description:"一级分类名称"`
  171. ClassifyIdSecond int `description:"二级分类id"`
  172. ClassifyNameSecond string `description:"二级分类名称"`
  173. Title string `description:"标题"`
  174. Abstract string `description:"摘要"`
  175. Author string `description:"作者"`
  176. Frequency string `description:"频度"`
  177. CreateTime string `description:"创建时间"`
  178. ModifyTime time.Time `description:"修改时间"`
  179. State int `description:"1:未发布,2:已发布"`
  180. PublishTime string `description:"发布时间"`
  181. Stage int `description:"期数"`
  182. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  183. Content string `description:"内容"`
  184. VideoUrl string `description:"音频文件URL"`
  185. VideoName string `description:"音频文件名称"`
  186. VideoPlaySeconds string `description:"音频播放时长"`
  187. VideoSize string `description:"音频文件大小,单位M"`
  188. ContentSub string `description:"内容前两个章节"`
  189. ClassifyName string `description:"分类名称"`
  190. HasPermission int `description:"报告权限:0:无权限,1:有权限"`
  191. TitleType string `description:"标题类型,FICC或者权益"`
  192. }
  193. func GetRecommendList(reportId, reportType int) (items []*RecommendReport, err error) {
  194. o := orm.NewOrmUsingDB("rddp")
  195. sql := `SELECT * FROM report WHERE state=2 AND id<>? `
  196. if reportType == 1 {
  197. sql += ` AND classify_name_first='权益研报' `
  198. } else {
  199. sql += ` AND classify_name_first<>'权益研报' `
  200. }
  201. sql += ` ORDER BY publish_time DESC LIMIT 3`
  202. _, err = o.Raw(sql, reportId).QueryRows(&items)
  203. return
  204. }
  205. func GetReportByCode(reportCode string) (item *Report, err error) {
  206. o := orm.NewOrmUsingDB("rddp")
  207. sql := `SELECT * FROM report WHERE report_code=?`
  208. err = o.Raw(sql, reportCode).QueryRow(&item)
  209. return
  210. }
  211. type ReportShareDetailResp struct {
  212. Report *Report `description:"报告"`
  213. Disclaimer string `description:"免责声明"`
  214. H5ShareName string `description:"研报分享抬头"`
  215. H5ReportShareImg string `description:"研报分享图片"`
  216. Hz int
  217. }
  218. type PcReport struct {
  219. Id int `description:"报告Id"`
  220. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  221. ClassifyIdFirst int `description:"一级分类id"`
  222. ClassifyNameFirst string `description:"一级分类名称"`
  223. ClassifyIdSecond int `description:"二级分类id"`
  224. ClassifyNameSecond string `description:"二级分类名称"`
  225. Title string `description:"标题"`
  226. Abstract string `description:"摘要"`
  227. Author string `description:"作者"`
  228. Frequency string `description:"频度"`
  229. CreateTime string `description:"创建时间"`
  230. ModifyTime time.Time `description:"修改时间"`
  231. State int `description:"1:未发布,2:已发布"`
  232. PublishTime string `description:"发布时间"`
  233. Stage int `description:"期数"`
  234. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  235. Content string `json:"-" description:"内容"`
  236. VideoUrl string `description:"音频文件URL"`
  237. VideoName string `description:"音频文件名称"`
  238. VideoPlaySeconds string `description:"音频播放时长"`
  239. VideoSize string `description:"音频文件大小,单位M"`
  240. ContentSub string `json:"-" description:"内容前两个章节"`
  241. IsShowNewLabel int `description:"是否显示新标签,等于0不显示,大于0显示"`
  242. IsCurrentDate int `description:"是否当前日期:1是,0不是"`
  243. ClassifyName string `description:"分类名称"`
  244. TitleType string `description:"标题类型,FICC或者权益"`
  245. }
  246. type ReportAuthor struct {
  247. ReportAuthor string `description:"报告作者名称"`
  248. }
  249. func GetReportAuthor(reportAuthor string) (item *ReportAuthor, err error) {
  250. o := orm.NewOrmUsingDB("rddp")
  251. sql := `SELECT * FROM report_author WHERE report_author=? `
  252. err = o.Raw(sql, reportAuthor).QueryRow(&item)
  253. return
  254. }
  255. // GetTrialReportByCode ETA试用-根据编码获取报告
  256. func GetTrialReportByCode(reportCode string) (item *Report, err error) {
  257. o := orm.NewOrmUsingDB("rddp_trial")
  258. sql := `SELECT * FROM report WHERE report_code=?`
  259. err = o.Raw(sql, reportCode).QueryRow(&item)
  260. return
  261. }