report.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package pc
  2. import (
  3. "fmt"
  4. "hongze/hongze_yb/global"
  5. "time"
  6. )
  7. type Report struct {
  8. Id int `description:"报告Id"`
  9. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  10. ClassifyIdFirst int `description:"一级分类id"`
  11. ClassifyNameFirst string `description:"一级分类名称"`
  12. ClassifyIdSecond int `description:"二级分类id"`
  13. ClassifyNameSecond string `description:"二级分类名称"`
  14. Title string `description:"标题"`
  15. Abstract string `description:"摘要"`
  16. Author string `description:"作者"`
  17. Frequency string `description:"频度"`
  18. CreateTime string `description:"创建时间"`
  19. ModifyTime time.Time `description:"修改时间"`
  20. State int `description:"1:未发布,2:已发布"`
  21. PublishTime string `description:"发布时间"`
  22. Stage int `description:"期数"`
  23. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  24. Content string `description:"内容"`
  25. VideoUrl string `description:"音频文件URL"`
  26. VideoName string `description:"音频文件名称"`
  27. VideoPlaySeconds string `description:"音频播放时长"`
  28. VideoSize string `description:"音频文件大小,单位M"`
  29. ContentSub string `description:"内容前两个章节"`
  30. ClassifyName string `description:"分类名称"`
  31. HasPermission int `description:"报告权限:0:无权限,1:有权限"`
  32. TitleType string `description:"标题类型,FICC或者权益"`
  33. }
  34. func GetLatestReportList() (items []*Report, err error) {
  35. sql := `SELECT * FROM report WHERE state=2 ORDER BY publish_time DESC LIMIT 3 `
  36. err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
  37. return
  38. }
  39. func GetRecommendList(reportId, reportType, secondId int) (items []*Report, err error) {
  40. sql := `SELECT * FROM report WHERE state=2 AND id<> %v AND classify_id_second=%v `
  41. sql = fmt.Sprintf(sql, reportId, secondId)
  42. if reportType == 1 {
  43. sql += ` AND classify_name_first='权益研报' `
  44. } else {
  45. sql += ` AND classify_name_first<>'权益研报' `
  46. }
  47. sql += ` ORDER BY publish_time DESC LIMIT 3`
  48. err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
  49. return
  50. }
  51. type LatestReport struct {
  52. Id int `description:"报告Id" json:"_"`
  53. ClassifyNameFirst string `description:"一级分类名称" json:"classify_name_first"`
  54. ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"`
  55. ClassifyIdSecond int `description:"二级分类id" json:"classify_id_second"`
  56. Title string `description:"标题" json:"title"`
  57. State int `description:"1:未发布,2:已发布" json:"state"`
  58. PublishTime time.Time `description:"发布时间" json:"publish_time"`
  59. Stage int `description:"期数" json:"stage"`
  60. ReportId int
  61. }
  62. func GetLatestStage(classifyNames []string) (items []*LatestReport, err error) {
  63. sql := `SELECT * FROM(SELECT DISTINCT
  64. classify_name_first,
  65. id,
  66. title,
  67. state,
  68. publish_time,
  69. stage
  70. FROM
  71. report
  72. WHERE
  73. classify_name_first IN (?)
  74. AND state IN (2, 6)
  75. ORDER BY
  76. publish_time DESC) t GROUP BY t.classify_name_first`
  77. err = global.MYSQL["rddp"].Raw(sql, classifyNames).Scan(&items).Error
  78. return
  79. }
  80. type RecommendResp struct {
  81. ReportId int
  82. ReportChapterID int
  83. Title string
  84. Stage int
  85. ClassifyNameFirst string
  86. ClassifySecondFirst string
  87. }
  88. type DetailBannerResp struct {
  89. ReportId int
  90. Stage int
  91. VipTitle string
  92. Author string
  93. ReportAuthor string
  94. ImgUrl string
  95. ClassifyNameFirst string
  96. ClassifyIdFirst int
  97. ClassifyNameSecond string
  98. ClassifyIdSecond int
  99. Type string
  100. ShowType uint8
  101. }
  102. type LatestReportBanner struct {
  103. ReportId int `description:"报告Id" json:"reportId"`
  104. ClassifyIdFirst int
  105. ClassifyIdSecond int
  106. ClassifyNameFirst string `description:"一级分类名称" json:"classify_name_first"`
  107. ClassifyNameSecond string `description:"二级分类名称" json:"classify_name_second"`
  108. Title string `description:"标题" json:"title"`
  109. State int `description:"1:未发布,2:已发布" json:"state"`
  110. PublishTime time.Time `description:"发布时间" json:"publish_time"`
  111. Stage int `description:"期数" json:"stage"`
  112. VipTitle string
  113. Author string
  114. ReportAuthor string
  115. }
  116. // GetRecommendListV2
  117. // @Description: 获取报告的推荐列表
  118. // @author: Roc
  119. // @datetime 2024-06-24 14:25:01
  120. // @param reportId int
  121. // @param reportType int
  122. // @param firstId int
  123. // @param secondId int
  124. // @param thirdId int
  125. // @return items []*Report
  126. // @return err error
  127. func GetRecommendListV2(reportId, reportType, firstId, secondId, thirdId int) (items []*Report, err error) {
  128. sql := `SELECT * FROM report WHERE state=2 AND id<> ? AND classify_id_first=? AND classify_id_second=? AND classify_id_third=? `
  129. if reportType == 1 {
  130. sql += ` AND classify_name_first = ? `
  131. } else {
  132. sql += ` AND classify_name_first<>? `
  133. }
  134. sql += ` ORDER BY publish_time DESC LIMIT 3`
  135. err = global.MYSQL["rddp"].Raw(sql, reportId, firstId, secondId, thirdId, "权益研报").Scan(&items).Error
  136. return
  137. }