report_selection.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package models
  2. import (
  3. "github.com/rdlucklib/rdluck_tools/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 string `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. }
  37. type ReportSelectionLetailResp struct {
  38. Detail *DetailCygxReportSelectionRep
  39. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  40. List []*ReportSelectionChartPermission
  41. }
  42. type ReportSelectionChartPermission struct {
  43. PermissionName string `description:"权限名称"`
  44. IcoLink string `orm:"column(image_url)"description:"图标链接"`
  45. List []*CygxReportSelectionLogDetail
  46. }
  47. type CygxReportSelectionLogDetail struct {
  48. IndustrialManagementId string `description:"产业Id"`
  49. SubjectName string `description:"标的名称"`
  50. Body string `description:"内容"`
  51. List []*IndustriaReportSelection
  52. }
  53. type IndustriaReportSelection struct {
  54. IndustrialManagementId int `description:"产业Id"`
  55. IndustryName string `description:"产业名称"`
  56. }
  57. type ReportSelectionId struct {
  58. ArticleId int `description:"报告I"`
  59. }
  60. //获取数量
  61. func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
  62. sqlCount := ` SELECT COUNT(1) AS count FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  63. if condition != "" {
  64. sqlCount += condition
  65. }
  66. o := orm.NewOrm()
  67. err = o.Raw(sqlCount, pars).QueryRow(&count)
  68. return
  69. }
  70. //通过纪要ID获取活动详情
  71. func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
  72. o := orm.NewOrm()
  73. sql := `SELECT * FROM cygx_report_selection WHERE article_id=? AND publish_status = 1 `
  74. err = o.Raw(sql, articleId).QueryRow(&item)
  75. return
  76. }
  77. //列表
  78. func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
  79. o := orm.NewOrm()
  80. sql := `SELECT * ,` + readSql + ` FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1 `
  81. if condition != "" {
  82. sql += condition
  83. }
  84. sql += ` ORDER BY art.publish_date DESC LIMIT ?,?`
  85. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  86. return
  87. }
  88. type CygxReportSelectionLog struct {
  89. ArticleSunId int `description:"子级报告id"`
  90. ArticleId int `description:"父级报告Id"`
  91. ChartPermissionId int `description:"行业ID"`
  92. PermissionName string `description:"行业ID"`
  93. CreateTime time.Time `description:"创建时间"`
  94. Body string `description:"内容"`
  95. IndustrialSubjectId string `description:"标的ID"`
  96. IndustrialManagementId string `description:"产业资源包Id 多个用 , 隔开"`
  97. SubjectName string `description:"标的名称"`
  98. IcoLink string `orm:"column(image_url)"description:"图标链接"`
  99. }
  100. //列表
  101. func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
  102. o := orm.NewOrm()
  103. sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.*
  104. FROM
  105. cygx_report_selection_log AS l
  106. INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id
  107. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id
  108. WHERE l.article_id = ? `
  109. _, err = o.Raw(sql, articleId).QueryRows(&items)
  110. return
  111. }
  112. //列表
  113. func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
  114. o := orm.NewOrm()
  115. sql := `SELECT c.permission_name ,s.subject_name , l.*
  116. FROM
  117. cygx_report_selection_log AS l
  118. INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id
  119. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id
  120. WHERE l.article_id = ? AND l.chart_permission_id =?`
  121. _, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
  122. return
  123. }
  124. func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaReportSelection, err error) {
  125. o := orm.NewOrm()
  126. sql := `SELECT * FROM cygx_industrial_management WHERE industrial_management_id IN (` + industrialManagementIds + `)`
  127. _, err = o.Raw(sql).QueryRows(&items)
  128. return
  129. }