report_selection.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type CygxReportSelectionRep struct {
  8. ArticleId int `orm:"column(article_id);pk"description:"报告id"`
  9. Title string `description:"标题"`
  10. Department string `description:"作者"`
  11. PublishDate string `description:"发布时间"`
  12. CreateTime string `description:"创建时间"`
  13. Abstract string `description:"摘要/更新说明"`
  14. UpdateDescription string `description:"更新说明"`
  15. IsRed bool `description:"是否标记红点"`
  16. ReadNum int `description:"阅读次数"`
  17. }
  18. type CygxReportSelectionListPublicRep struct {
  19. Paging *paging.PagingItem `description:"分页数据"`
  20. List []*CygxReportSelectionRep
  21. }
  22. type DetailCygxReportSelectionRep struct {
  23. ArticleId int `description:"报告Id"`
  24. Title string `description:"标题"`
  25. Department string `description:"作者"`
  26. PublishDate string `description:"发布时间"`
  27. CreateTime string `description:"创建时间"`
  28. LastUpdatedTime string `description:"最后一次更新时间"`
  29. Periods int `description:"期数"`
  30. VideoUrl string `description:"链接"`
  31. VideoPlaySeconds string `description:"时长"`
  32. VideoName string `description:"音频名称"`
  33. ProductDescription string `description:"产品说明"`
  34. UpdateDescription string `description:"更新说明"`
  35. FocusOn string `description:"近期重点关注方向"`
  36. MarketStrategy string `description:"市场策略核心逻辑汇总"`
  37. ReportLink string `description:"报告链接"`
  38. CeLueArticleId int `description:"策略报告详情"`
  39. }
  40. type ReportSelectionLetailResp struct {
  41. Detail *DetailCygxReportSelectionRep
  42. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  43. List []*ReportSelectionChartPermission
  44. ListPermissionSubject []*ReportSelectionChartLogPermission `description:"行业列表"`
  45. }
  46. type ReportSelectionChartPermission struct {
  47. PermissionName string `description:"权限名称"`
  48. IcoLink string `orm:"column(image_url)"description:"图标链接"`
  49. List []*CygxReportSelectionLogDetail
  50. BodyChartSummary string `description:"行业核心逻辑汇总"`
  51. }
  52. type ReportSelectionChartLogPermission struct {
  53. PermissionName string `description:"权限名称"`
  54. ListSubject []*ReportSelectionChartLogSubjectName `description:"标的列表"`
  55. }
  56. type ReportSelectionChartLogSubjectName struct {
  57. SubjectName string `description:"标的名称"`
  58. IndustrialSubjectId int `description:"标的ID"`
  59. IsNew bool `description:"是否展示新标签"`
  60. }
  61. type CygxReportSelectionLogDetail struct {
  62. IndustrialManagementId string `description:"产业Id"`
  63. IndustrialSubjectId int `description:"标的ID"`
  64. SubjectName string `description:"标的名称"`
  65. IsNew bool `description:"是否展示新标签"`
  66. Body string `description:"内容"`
  67. CompanyLabel []string `description:"公司标签"`
  68. Label string `description:"公司标签"`
  69. OverviewArticleId int `description:"综述报告Id"`
  70. List []*IndustriaReportSelection
  71. }
  72. type IndustriaReportSelection struct {
  73. IndustrialManagementId int `description:"产业Id"`
  74. IndustryName string `description:"产业名称"`
  75. }
  76. type ReportSelectionId struct {
  77. ArticleId int `description:"报告I"`
  78. }
  79. // 获取数量
  80. func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
  81. sqlCount := ` SELECT COUNT(1) AS count FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  82. if condition != "" {
  83. sqlCount += condition
  84. }
  85. o := orm.NewOrm()
  86. err = o.Raw(sqlCount, pars).QueryRow(&count)
  87. return
  88. }
  89. // 通过ID获取详情
  90. func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
  91. o := orm.NewOrm()
  92. sql := `SELECT * FROM cygx_report_selection WHERE article_id=? AND publish_status = 1 `
  93. err = o.Raw(sql, articleId).QueryRow(&item)
  94. return
  95. }
  96. // 通过期数获取详情
  97. func GetCygxReportSelectionInfoByperiods(periods int) (item *DetailCygxReportSelectionRep, err error) {
  98. o := orm.NewOrm()
  99. sql := `SELECT * FROM cygx_report_selection WHERE periods=? `
  100. err = o.Raw(sql, periods).QueryRow(&item)
  101. return
  102. }
  103. // 列表
  104. func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
  105. o := orm.NewOrm()
  106. sql := `SELECT * ,` + readSql + ` FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  107. if condition != "" {
  108. sql += condition
  109. }
  110. sql += ` ORDER BY art.publish_date DESC LIMIT ?,?`
  111. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  112. return
  113. }
  114. type CygxReportSelectionLog struct {
  115. ArticleSunId int `description:"子级报告id"`
  116. ArticleId int `description:"父级报告Id"`
  117. ChartPermissionId int `description:"行业ID"`
  118. PermissionName string `description:"行业ID"`
  119. CreateTime time.Time `description:"创建时间"`
  120. Body string `description:"内容"`
  121. IndustrialSubjectId int `description:"标的ID"`
  122. IndustrialManagementId string `description:"产业资源包Id 多个用 , 隔开"`
  123. SubjectName string `description:"标的名称"`
  124. IcoLink string `orm:"column(image_url)"description:"图标链接"`
  125. CompanyLabel []string `description:"公司标签"`
  126. Label string `description:"公司标签"`
  127. OverviewArticleId int `description:"综述报告Id"`
  128. }
  129. // 列表
  130. func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
  131. o := orm.NewOrm()
  132. sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.* ,l.company_label as label
  133. FROM
  134. cygx_report_selection_log AS l
  135. INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id
  136. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id
  137. WHERE l.article_id = ? `
  138. _, err = o.Raw(sql, articleId).QueryRows(&items)
  139. return
  140. }
  141. // 列表
  142. func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
  143. o := orm.NewOrm()
  144. sql := `SELECT c.permission_name , l.* ,l.company_label as label
  145. FROM
  146. cygx_report_selection_log AS l
  147. INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id
  148. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id
  149. WHERE l.article_id = ? AND l.chart_permission_id =?`
  150. _, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
  151. return
  152. }
  153. func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaReportSelection, err error) {
  154. o := orm.NewOrm()
  155. sql := `SELECT * FROM cygx_industrial_management WHERE industrial_management_id IN (` + industrialManagementIds + `)`
  156. _, err = o.Raw(sql).QueryRows(&items)
  157. return
  158. }