report_mapping.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ReportMapping struct {
  6. CategoryId int `description:"分类ID"`
  7. SubCategoryName string `description:"主题"`
  8. MatchTypeName string `description:"分类名称"`
  9. ChartPermissionName string `description:"行业名称"`
  10. ChartPermissionId int `description:"行业ID"`
  11. IsRed bool `description:"是否标红"`
  12. PermissionType int `description:"1主观,2客观"`
  13. }
  14. type ReportMappingHome struct {
  15. CategoryId int `description:"分类ID"`
  16. SubCategoryName string `description:"主题名称"`
  17. MatchTypeName string `description:"匹配类型"`
  18. IsRed bool `description:"是否标红"`
  19. }
  20. type TradeReportMapping struct {
  21. CategoryId int `description:"分类ID"`
  22. MatchTypeName string `description:"匹配类型"`
  23. IsRed bool `description:"是否标红"`
  24. IsFollow bool `description:"是否关注"`
  25. UpdateTime string `description:"更新时间"`
  26. Readnum int `description:"阅读数量"`
  27. ListArticle []*HomeArticle `description:"文章列表"`
  28. }
  29. type ReportMappingResp struct {
  30. List []*ReportMapping
  31. }
  32. type ReportMappingHomeResp struct {
  33. List []*ReportMappingHome
  34. }
  35. type TradeReportMappingResp struct {
  36. List []*TradeReportMapping
  37. }
  38. //获取所有分类
  39. func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT * FROM cygx_report_mapping WHERE 1=1 ORDER BY sort ASC `
  42. _, err = o.Raw(sql).QueryRows(&items)
  43. return
  44. }
  45. //获取策略下面的所有分类
  46. func GetReportMappingStrategyHomeAll() (items []*TradeReportMapping, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT
  49. MAX( art.publish_date ) AS update_time,
  50. re.category_id,re.sub_category_name,re.match_type_name
  51. FROM
  52. cygx_report_mapping AS re
  53. INNER JOIN cygx_article AS art ON art.category_id = re.category_id
  54. WHERE
  55. re.report_type = 1
  56. AND re.chart_permission_id = 23
  57. GROUP BY
  58. re.match_type_name
  59. ORDER BY
  60. sort DESC , art.publish_date DESC`
  61. _, err = o.Raw(sql).QueryRows(&items)
  62. return
  63. }
  64. //行业列表
  65. func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error) {
  66. o := orm.NewOrm()
  67. sql := `SELECT
  68. MAX( art.publish_date ) AS update_time,
  69. re.category_id,
  70. re.sub_category_name,
  71. re.match_type_name
  72. FROM
  73. cygx_report_mapping AS re
  74. INNER JOIN cygx_article AS art ON re.category_id = art.category_id
  75. WHERE
  76. re.chart_permission_id =?
  77. AND re.report_type = 1
  78. AND art.is_class = 1
  79. AND re.category_id NOT IN (67)
  80. GROUP BY
  81. art.category_id
  82. ORDER BY
  83. update_time DESC`
  84. _, err = o.Raw(sql, ChartPermissionId).QueryRows(&items)
  85. return
  86. }
  87. type IndustrialToArticleCategoryRep struct {
  88. CategoryId int `description:"分类ID"`
  89. MatchTypeName string `description:"匹配类型"`
  90. IsRed bool `description:"是否标红"`
  91. }
  92. type IndustrialToArticleCategoryListRep struct {
  93. LayoutTime string `description:"布局时间"`
  94. IndustryName string `description:"产业名称"`
  95. IndustrialManagementId int `description:"产业D"`
  96. List []*IndustrialToArticleCategoryRep
  97. ListSubject []*IndustrialSubject
  98. IndustryVideo *MicroVideoSimpleInfo
  99. AuthInfo *UserPermissionAuthInfo
  100. }
  101. //通过分类ID获取详情
  102. func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
  103. o := orm.NewOrm()
  104. sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? LIMIT 1 `
  105. err = o.Raw(sql, categoryId).QueryRow(&item)
  106. return
  107. }
  108. //通过分类ID获取详情
  109. func GetdetailByCategoryIdPush(categoryId int) (item *ReportMapping, err error) {
  110. o := orm.NewOrm()
  111. sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? `
  112. err = o.Raw(sql, categoryId).QueryRow(&item)
  113. return
  114. }
  115. //通过分类ID获取详情主观客观
  116. func GetdetailByCategoryIdSando(categoryId int) (item *ReportMapping, err error) {
  117. o := orm.NewOrm()
  118. sql := `SELECT * FROM cygx_report_mapping WHERE permission_type>0 AND category_id=? LIMIT 1`
  119. err = o.Raw(sql, categoryId).QueryRow(&item)
  120. return
  121. }
  122. //通过分类ID获取详情
  123. func GetdetailByCategoryIdOne(categoryId int) (item *ReportMapping, err error) {
  124. o := orm.NewOrm()
  125. sql := `SELECT * FROM cygx_report_mapping WHERE category_id=? LIMIT 1`
  126. err = o.Raw(sql, categoryId).QueryRow(&item)
  127. return
  128. }
  129. //通过分类ID获取详情
  130. func GetdetailByCategoryIdSet(categoryId int) (ids string, err error) {
  131. o := orm.NewOrm()
  132. sql := `SELECT
  133. GROUP_CONCAT( DISTINCT category_id SEPARATOR ',' ) AS ids
  134. FROM
  135. cygx_report_mapping
  136. WHERE
  137. category_id_set = ? `
  138. err = o.Raw(sql, categoryId).QueryRow(&ids)
  139. return
  140. }
  141. //判断该分类下最新的文章用户是否阅读
  142. func CheckThisCategoryNewArticleIsRead(uid, categoryId int) (count int, err error) {
  143. o := orm.NewOrm()
  144. sql := `SELECT COUNT(1) count
  145. FROM cygx_article_history_record
  146. WHERE user_id = ?
  147. AND article_id = ( SELECT article_id FROM cygx_article WHERE category_id = ? AND is_class = 1 AND is_report = 1 AND is_filter = 0 ORDER BY publish_date DESC LIMIT 1)`
  148. err = o.Raw(sql, uid, categoryId).QueryRow(&count)
  149. return
  150. }
  151. //获取策略下面的所有分类
  152. func GetMatchTypeNamenNotNull() (items []*ReportMapping, err error) {
  153. o := orm.NewOrm()
  154. sql := `SELECT category_id,match_type_name FROM cygx_report_mapping WHERE match_type_name <> ''`
  155. _, err = o.Raw(sql).QueryRows(&items)
  156. return
  157. }
  158. type ReportMappingStatistical struct {
  159. CategoryId int `description:"分类ID"`
  160. SubCategoryName string `description:"主题名称"`
  161. MatchTypeName string `description:"匹配类型"`
  162. IsSummary string `description:"是否属于纪要,1 是,0否"`
  163. IsClass string `description:"是否归类,1 是,0否"`
  164. Pv int `description:"Pv"`
  165. Uv int `description:"Uv"`
  166. }