home.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. )
  6. type HomeArtAndChartListResp struct {
  7. Paging *paging.PagingItem
  8. List []*HomeArticle `description:"文章列表"`
  9. ChartList []*HomeChartListResp `description:"图表列表"`
  10. }
  11. type HomeArticleListResp struct {
  12. Paging *paging.PagingItem
  13. List []*ArticleListResp `description:"文章列表"`
  14. }
  15. type ReportBillboardListResp struct {
  16. List []*ArticleListResp `description:"文章列表"`
  17. }
  18. type HomeArticle struct {
  19. ArticleId int `description:"文章id"`
  20. Title string `description:"标题"`
  21. TitleEn string `description:"英文标题 "`
  22. PublishDate string `description:"发布时间"`
  23. Body string `description:"内容"`
  24. BodyHtml string `description:"内容带有HTML标签"`
  25. Abstract string `description:"摘要"`
  26. CategoryName string `description:"一级分类"`
  27. SubCategoryName string `description:"二级分类"`
  28. IsResearch bool `description:"是否属于研选"`
  29. Pv int `description:"PV"`
  30. ImgUrlPc string `description:"图片链接"`
  31. CategoryId string `description:"文章分类"`
  32. HttpUrl string `description:"文章链接跳转地址"`
  33. IsNeedJump bool `description:"是否需要跳转链接地址"`
  34. Source int `description:"来源 1:文章, 2:图表"`
  35. Annotation string `description:"核心观点"`
  36. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  37. MicroAudio *MicroAudioUnionList `description:"微路演音频"`
  38. List []*IndustrialManagementIdInt
  39. }
  40. type ArticleListResp struct {
  41. ArticleId int `description:"文章id"`
  42. Title string `description:"标题"`
  43. TitleEn string `description:"英文标题 "`
  44. PublishDate string `description:"发布时间"`
  45. Body string `description:"内容"`
  46. Abstract string `description:"摘要"`
  47. ExpertBackground string `description:"专家背景"`
  48. IsResearch bool `description:"是否属于研选"`
  49. Pv int `description:"PV"`
  50. ImgUrlPc string `description:"图片链接"`
  51. CategoryId string `description:"文章分类"`
  52. HttpUrl string `description:"文章链接跳转地址"`
  53. IsNeedJump bool `description:"是否需要跳转链接地址"`
  54. Source int `description:"来源 1:文章, 2:图表"`
  55. Annotation string `description:"核心观点"`
  56. ChartPermissionName string `description:"权限名称"`
  57. List []*IndustrialManagementIdInt
  58. }
  59. type HomeChartListResp struct {
  60. ChartId int `description:"图表ID"`
  61. Title string `description:"标题"`
  62. TitleEn string `description:"英文标题 "`
  63. CreateDate string `description:"创建时间"`
  64. PtagName string `description:"父类名称"`
  65. CtagName string `description:"子类名称"`
  66. PtagNameTwo string `description:"父类名称"`
  67. CtagNameTwo string `description:"子类名称"`
  68. CtagNamePc string `description:"Pc端所有的分类名称"`
  69. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  70. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  71. IsNeedJump bool `description:"是否需要跳转链接地址"`
  72. IsTop bool `description:"是否置顶"`
  73. NumTop int `description:"置顶数量"`
  74. Source int `description:"来源 1:文章, 2:图表"`
  75. LabelList []*LabelList `description:"图表标签列表"`
  76. }
  77. type LabelList struct {
  78. PtagName string `description:"父类名称"`
  79. CtagName string `description:"子类名称"`
  80. }
  81. func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
  82. o := orm.NewOrm()
  83. sql := `SELECT COUNT(1) AS count
  84. FROM cygx_article AS a
  85. WHERE a.publish_status=1 `
  86. if condition != "" {
  87. sql += condition
  88. }
  89. err = o.Raw(sql, pars).QueryRow(&count)
  90. return
  91. }
  92. func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
  93. o := orm.NewOrm()
  94. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  95. FROM cygx_article AS a
  96. WHERE a.publish_status=1 `
  97. if condition != "" {
  98. sql += condition
  99. }
  100. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  101. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  102. return
  103. }
  104. func GetHomeListPublic(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
  105. o := orm.NewOrm()
  106. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  107. FROM cygx_article AS a
  108. WHERE a.publish_status=1 `
  109. if condition != "" {
  110. sql += condition
  111. }
  112. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  113. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  114. return
  115. }
  116. func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
  117. o := orm.NewOrm()
  118. sql := ` SELECT *
  119. FROM cygx_article AS a
  120. WHERE a.publish_status=1 `
  121. if condition != "" {
  122. sql += condition
  123. }
  124. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  125. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  126. return
  127. }