tactics.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "strconv"
  6. "time"
  7. )
  8. type Tactics struct {
  9. ArticleId int `description:"文章id"`
  10. Title string `description:"标题"`
  11. TitleEn string `description:"英文标题"`
  12. UpdateFrequency string `description:"更新周期"`
  13. PublishDate time.Time `description:"发布时间"`
  14. PublishStatus int `description:"发布状态"`
  15. Department string `description:"作者"`
  16. Body string `description:"内容"`
  17. Abstract string `description:"摘要"`
  18. Annotation string `description:"注解"`
  19. CategoryName string `description:"分类"`
  20. SubCategoryName string `description:"子级分类"`
  21. CategoryId int `description:"分类id"`
  22. CreateDate string `description:"创建日期"`
  23. }
  24. func GetTacticsList(endDate string) (list []*Tactics, err error) {
  25. o := orm.NewOrmUsingDB("tactics")
  26. sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id
  27. FROM article_articleinfo AS a
  28. INNER JOIN article_content AS b ON a.id=b.article_id
  29. INNER JOIN article_category AS c ON a.id=c.article_id
  30. INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
  31. WHERE a.publish_status=1 AND a.publish_date>=? AND d.id IN (28,32,45,57,62,72,74,79,84,86,88,90,93,95,96,98)
  32. AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
  33. _, err = o.Raw(sql, endDate).QueryRows(&list)
  34. return
  35. }
  36. func GetTacticsListAll() (list []*Tactics, err error) {
  37. o := orm.NewOrmUsingDB("tactics")
  38. sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id
  39. FROM article_articleinfo AS a
  40. INNER JOIN article_content AS b ON a.id=b.article_id
  41. INNER JOIN article_category AS c ON a.id=c.article_id
  42. INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
  43. WHERE a.publish_status=1 AND d.id IN (28,32,45,57,62,72,74,79,84,86,88,90,93,95,96,98)
  44. AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
  45. //IN(85,71)
  46. _, err = o.Raw(sql).QueryRows(&list)
  47. return
  48. }
  49. func GetCygxArticleListAll() (list []*Tactics, err error) {
  50. o := orm.NewOrm()
  51. sql := `SELECT * FROM cygx_article `
  52. _, err = o.Raw(sql).QueryRows(&list)
  53. return
  54. }
  55. type Tactics2 struct {
  56. ArticleId int `description:"文章id"`
  57. Title string `description:"标题"`
  58. TitleEn string `description:"英文标题"`
  59. UpdateFrequency string `description:"更新周期"`
  60. PublishDate time.Time `description:"发布时间"`
  61. PublishStatus int `description:"发布状态"`
  62. Department string `description:"作者"`
  63. Body string `description:"内容"`
  64. Abstract string `description:"摘要"`
  65. Annotation string `description:"注解"`
  66. CategoryName string `description:"分类"`
  67. SubCategoryName string `description:"子级分类"`
  68. CategoryId int `description:"分类id"`
  69. CategoryIdTwo int `description:"分类id"`
  70. CreateDate string `description:"创建日期"`
  71. IsClass int `description:"是否归类,1是,0否"`
  72. IsSummary int `description:"是否是纪要库,1是,0否"`
  73. IsReport int `description:"是否属于报告,1是,0否"`
  74. ReportType int `description:"报告类型,1行业报告,2产业报告,0无"`
  75. Stock string `description:"个股标签"`
  76. FieldName string `description:"产业标签"`
  77. File string `description:"Pdf下载链接"`
  78. TypeName string `description:"策略平台报告类型"`
  79. UpdateDate string `description:"策略平台报告更新时间"`
  80. CeLueFieldId int `description:"策略平台领域ID"`
  81. Cover string `description:"封面图片"`
  82. }
  83. func GetTacticsList2(endDate string) (list []*Tactics2, err error) {
  84. o := orm.NewOrmUsingDB("tactics")
  85. sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id
  86. FROM article_articleinfo AS a
  87. INNER JOIN article_content AS b ON a.id=b.article_id
  88. INNER JOIN article_category AS c ON a.id=c.article_id
  89. INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
  90. WHERE a.publish_status=1 AND a.publish_date>=? AND d.id IN (7,9,11,28,32,45,51,52,57,62,64,65,66,67,69,71,72,74,79,80,84,85,86,87,88,89,90,93,95,96,98,100,102)`
  91. //AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
  92. //IN(85,71)
  93. _, err = o.Raw(sql, endDate).QueryRows(&list)
  94. return
  95. }
  96. func GetTacticsListAll2() (list []*Tactics2, err error) {
  97. o := orm.NewOrmUsingDB("tactics")
  98. sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id
  99. FROM article_articleinfo AS a
  100. INNER JOIN article_content AS b ON a.id=b.article_id
  101. INNER JOIN article_category AS c ON a.id=c.article_id
  102. INNER JOIN article_categoryinfo AS d ON c.category_id=d.id
  103. WHERE a.publish_status=1 AND d.id IN (7,9,11,28,32,45,51,52,57,62,64,65,66,67,69,71,72,74,79,80,84,85,86,87,88,89,90,93,95,96,98,100) `
  104. //AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) `
  105. //IN(85,71)
  106. _, err = o.Raw(sql).QueryRows(&list)
  107. return
  108. }
  109. type TacticsListResp struct {
  110. Paging *paging.PagingItem
  111. MatchTypeName string `description:"匹配类型"`
  112. ChartPermissionId int `description:"行业ID"`
  113. CategoryImgUrlPc string `description:"图片"`
  114. IsShowAbstract bool `description:"是否展示摘要"`
  115. List []*ReportArticle
  116. }
  117. func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*ReportArticle, err error) {
  118. o := orm.NewOrm()
  119. sql := ` SELECT * ,(SELECT COUNT(1) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id=a.article_id) AS readnum
  120. FROM cygx_article AS a
  121. WHERE a.publish_status=1 `
  122. if condition != "" {
  123. sql += condition
  124. }
  125. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  126. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  127. return
  128. }
  129. type TimeLineReportListResp struct {
  130. Paging *paging.PagingItem
  131. MatchTypeName string `description:"匹配类型"`
  132. CategoryImgUrlPc string `description:"图片"`
  133. List []*TimeLineReportItem
  134. }