report_selection.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. VisibleRange int `description:"设置可见范围1全部,0内部"`
  40. }
  41. type ReportSelectionLetailResp struct {
  42. Detail *DetailCygxReportSelectionRep
  43. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  44. List []*ReportSelectionChartPermission
  45. ListPermissionSubject []*ReportSelectionChartLogPermission `description:"行业列表"`
  46. IsShow bool `description:"是否展示"`
  47. }
  48. type ReportSelectionChartPermission struct {
  49. PermissionName string `description:"权限名称"`
  50. ChartPermissionId int `description:"权限名称"`
  51. IcoLink string `orm:"column(image_url)"description:"图标链接"`
  52. List []*CygxReportSelectionLogDetail
  53. BodyChartSummary string `description:"行业核心逻辑汇总"`
  54. }
  55. type ReportSelectionChartLogPermission struct {
  56. PermissionName string `description:"权限名称"`
  57. ListSubject []*ReportSelectionChartLogSubjectName `description:"标的列表"`
  58. }
  59. type ReportSelectionChartLogSubjectName struct {
  60. SubjectName string `description:"标的名称"`
  61. IndustrialSubjectId int `description:"标的ID"`
  62. IsNew bool `description:"是否展示新标签"`
  63. }
  64. type CygxReportSelectionLogDetail struct {
  65. IndustrialManagementId string `description:"产业Id"`
  66. IndustrialSubjectId int `description:"标的ID"`
  67. SubjectName string `description:"标的名称"`
  68. IsNew bool `description:"是否展示新标签"`
  69. Body string `description:"内容"`
  70. CompanyLabel []string `description:"公司标签"`
  71. Label string `description:"公司标签"`
  72. OverviewArticleId int `description:"综述报告Id"`
  73. List []*IndustriaReportSelection
  74. }
  75. type IndustriaReportSelection struct {
  76. IndustrialManagementId int `description:"产业Id"`
  77. IndustryName string `description:"产业名称"`
  78. }
  79. type ReportSelectionId struct {
  80. ArticleId int `description:"报告I"`
  81. }
  82. // 获取数量
  83. func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
  84. sqlCount := ` SELECT COUNT(1) AS count FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  85. if condition != "" {
  86. sqlCount += condition
  87. }
  88. o := orm.NewOrm()
  89. err = o.Raw(sqlCount, pars).QueryRow(&count)
  90. return
  91. }
  92. // 通过ID获取详情
  93. func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
  94. o := orm.NewOrm()
  95. sql := `SELECT * FROM cygx_report_selection WHERE article_id=? AND publish_status = 1 `
  96. err = o.Raw(sql, articleId).QueryRow(&item)
  97. return
  98. }
  99. // 通过期数获取详情
  100. func GetCygxReportSelectionInfoByperiods(periods int) (item *DetailCygxReportSelectionRep, err error) {
  101. o := orm.NewOrm()
  102. sql := `SELECT * FROM cygx_report_selection WHERE periods=? `
  103. err = o.Raw(sql, periods).QueryRow(&item)
  104. return
  105. }
  106. // 列表
  107. func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
  108. o := orm.NewOrm()
  109. sql := `SELECT * ,` + readSql + ` FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  110. if condition != "" {
  111. sql += condition
  112. }
  113. sql += ` ORDER BY art.publish_date DESC LIMIT ?,?`
  114. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  115. return
  116. }
  117. // 列表
  118. func GetReportSelectionListHome(condition, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
  119. o := orm.NewOrm()
  120. sql := `SELECT * FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  121. if condition != "" {
  122. sql += condition
  123. }
  124. sql += ` ORDER BY art.publish_date DESC LIMIT ?,?`
  125. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  126. return
  127. }
  128. type CygxReportSelectionLog struct {
  129. ArticleSunId int `description:"子级报告id"`
  130. ArticleId int `description:"父级报告Id"`
  131. ChartPermissionId int `description:"行业ID"`
  132. PermissionName string `description:"行业ID"`
  133. CreateTime time.Time `description:"创建时间"`
  134. Body string `description:"内容"`
  135. IndustrialSubjectId int `description:"标的ID"`
  136. IndustrialManagementId string `description:"产业资源包Id 多个用 , 隔开"`
  137. SubjectName string `description:"标的名称"`
  138. IcoLink string `orm:"column(image_url)"description:"图标链接"`
  139. CompanyLabel []string `description:"公司标签"`
  140. Label string `description:"公司标签"`
  141. OverviewArticleId int `description:"综述报告Id"`
  142. }
  143. // 列表
  144. func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
  145. o := orm.NewOrm()
  146. sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.* ,l.company_label as label
  147. FROM
  148. cygx_report_selection_log AS l
  149. INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id
  150. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id
  151. WHERE l.article_id = ? `
  152. _, err = o.Raw(sql, articleId).QueryRows(&items)
  153. return
  154. }
  155. // 列表
  156. func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
  157. o := orm.NewOrm()
  158. sql := `SELECT c.permission_name , l.* ,l.company_label as label
  159. FROM
  160. cygx_report_selection_log AS l
  161. INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id
  162. LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id
  163. WHERE l.article_id = ? AND l.chart_permission_id =?`
  164. _, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
  165. return
  166. }
  167. func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaReportSelection, err error) {
  168. o := orm.NewOrm()
  169. sql := `SELECT * FROM cygx_industrial_management WHERE industrial_management_id IN (` + industrialManagementIds + `)`
  170. _, err = o.Raw(sql).QueryRows(&items)
  171. return
  172. }