report_mapping.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package models
  2. import (
  3. "rdluck_tools/orm"
  4. )
  5. type ReportMapping struct {
  6. CategoryId int `description:"分类ID"`
  7. SubCategoryName string `description:"主题"`
  8. MatchTypeName string `description:"分类名称"`
  9. IsRed bool `description:"是否标红"`
  10. }
  11. type ReportMappingHome struct {
  12. CategoryId int `description:"分类ID"`
  13. SubCategoryName string `description:"主题名称"`
  14. MatchTypeName string `description:"匹配类型"`
  15. IsRed bool `description:"是否标红"`
  16. }
  17. type TradeReportMapping struct {
  18. CategoryId int `description:"分类ID"`
  19. SubCategoryName string `description:"主题名称"`
  20. MatchTypeName string `description:"匹配类型"`
  21. IsRed bool `description:"是否标红"`
  22. UpdateTime string `description:"更新时间"`
  23. Readnum int `description:"阅读数量"`
  24. }
  25. type ReportMappingResp struct {
  26. List []*ReportMapping
  27. }
  28. type ReportMappingHomeResp struct {
  29. List []*ReportMappingHome
  30. }
  31. type TradeReportMappingResp struct {
  32. List []*TradeReportMapping
  33. }
  34. //获取策略下面的所有分类
  35. func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
  36. o := orm.NewOrm()
  37. sql := `SELECT * FROM cygx_report_mapping WHERE report_type=1 AND chart_permission_id=23 ORDER BY sort ASC `
  38. _, err = o.Raw(sql).QueryRows(&items)
  39. return
  40. }
  41. //获取策略下面的所有分类
  42. func GetReportMappingStrategyHomeAll() (items []*ReportMappingHome, err error) {
  43. o := orm.NewOrm()
  44. sql := `SELECT
  45. re.category_id,re.sub_category_name,re.match_type_name
  46. FROM
  47. cygx_report_mapping AS re
  48. INNER JOIN cygx_article AS art ON art.category_id = re.category_id
  49. WHERE
  50. re.report_type = 1
  51. AND re.chart_permission_id = 23
  52. GROUP BY
  53. re.match_type_name
  54. ORDER BY
  55. sort DESC , art.publish_date DESC`
  56. _, err = o.Raw(sql).QueryRows(&items)
  57. return
  58. }
  59. //行业列表
  60. func GetTradeAll(uid, ChartPermissionId int) (items []*TradeReportMapping, err error) {
  61. o := orm.NewOrm()
  62. //sql := `SELECT * FROM cygx_report_mapping WHERE chart_permission_id = ? AND report_type = 1;`
  63. sql := `SELECT
  64. art.article_id,art.publish_date as update_time ,re.category_id,re.sub_category_name,( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ? AND rec.article_id = art.article_id ) AS readnum
  65. FROM
  66. cygx_report_mapping as re
  67. INNER JOIN cygx_article as art ON re.category_id = art.category_id
  68. WHERE
  69. re.chart_permission_id = ?
  70. AND re.report_type = 1
  71. AND art.is_class = 1
  72. AND re.chart_permission_id != 21
  73. ORDER BY art.publish_date DESC
  74. LIMIT 0,1`
  75. _, err = o.Raw(sql, uid, ChartPermissionId).QueryRows(&items)
  76. return
  77. }
  78. type IndustrialToArticleCategoryRep struct {
  79. CategoryId int `description:"分类ID"`
  80. MatchTypeName string `description:"匹配类型"`
  81. IsRed bool `description:"是否标红"`
  82. }
  83. type IndustrialToArticleCategoryListRep struct {
  84. LayoutTime string `description:"布局时间"`
  85. IndustryName string `description:"产业名称"`
  86. IndustrialManagementId int `description:"产业D"`
  87. List []*IndustrialToArticleCategoryRep
  88. }
  89. //通过分类ID获取详情
  90. func GetdetailByCategoryId(categoryId int) (item *ReportMapping, err error) {
  91. o := orm.NewOrm()
  92. sql := `SELECT * FROM cygx_report_mapping WHERE report_type=1 AND category_id=? `
  93. err = o.Raw(sql, categoryId).QueryRow(&item)
  94. return
  95. }