home.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "strconv"
  6. )
  7. type HomeArtAndChartListResp struct {
  8. Paging *paging.PagingItem
  9. List []*HomeArticle `description:"文章列表"`
  10. ChartList []*HomeChartListResp `description:"图表列表"`
  11. }
  12. type HomeArticleListResp struct {
  13. Paging *paging.PagingItem
  14. List []*ArticleListResp `description:"文章列表"`
  15. }
  16. type ReportBillboardListResp struct {
  17. List []*ArticleListResp `description:"文章列表"`
  18. }
  19. type HomeArticle struct {
  20. ArticleId int `description:"文章id"`
  21. Title string `description:"标题"`
  22. TitleEn string `description:"英文标题 "`
  23. PublishDate string `description:"发布时间"`
  24. Body string `description:"内容"`
  25. BodyHtml string `description:"内容带有HTML标签"`
  26. Abstract string `description:"摘要"`
  27. CategoryName string `description:"一级分类"`
  28. SubCategoryName string `description:"二级分类"`
  29. IsResearch bool `description:"是否属于研选"`
  30. Pv int `description:"PV"`
  31. ImgUrlPc string `description:"图片链接"`
  32. CategoryId string `description:"文章分类"`
  33. HttpUrl string `description:"文章链接跳转地址"`
  34. IsNeedJump bool `description:"是否需要跳转链接地址"`
  35. Source int `description:"来源 1:文章, 2:图表"`
  36. Annotation string `description:"核心观点"`
  37. ArticleTypeId int `description:"文章类型ID判断是否是研选使用"`
  38. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  39. Readnum int `description:"阅读数量"`
  40. IsRed bool `description:"是否标红"`
  41. MicroAudio *MicroAudioUnionList `description:"微路演音频"`
  42. List []*IndustrialManagementIdInt
  43. }
  44. type ArticleListResp struct {
  45. ArticleId int `description:"文章id"`
  46. Title string `description:"标题"`
  47. TitleEn string `description:"英文标题 "`
  48. PublishDate string `description:"发布时间"`
  49. Body string `description:"内容"`
  50. Abstract string `description:"摘要"`
  51. ExpertBackground string `description:"专家背景"`
  52. IsResearch bool `description:"是否属于研选"`
  53. Pv int `description:"PV"`
  54. ImgUrlPc string `description:"图片链接"`
  55. CategoryId string `description:"文章分类"`
  56. HttpUrl string `description:"文章链接跳转地址"`
  57. IsNeedJump bool `description:"是否需要跳转链接地址"`
  58. Source int `description:"来源 1:文章, 2:图表"`
  59. Annotation string `description:"核心观点"`
  60. ChartPermissionName string `description:"权限名称"`
  61. ArticleTypeId int `description:"文章类型ID判断是否是研选使用"`
  62. BodyImg string `description:"文章封面图片"`
  63. DepartmentId int `description:"作者Id"`
  64. NickName string `description:"作者昵称"`
  65. IsCollect bool `description:"本人是否收藏"`
  66. IsRed bool `description:"是否标红"`
  67. CollectNum int `description:"收藏人数"`
  68. List []*IndustrialManagementIdInt
  69. }
  70. type HomeChartListResp struct {
  71. ChartId int `description:"图表ID"`
  72. Title string `description:"标题"`
  73. TitleEn string `description:"英文标题 "`
  74. CreateDate string `description:"创建时间"`
  75. PtagName string `description:"父类名称"`
  76. CtagName string `description:"子类名称"`
  77. PtagNameTwo string `description:"父类名称"`
  78. CtagNameTwo string `description:"子类名称"`
  79. CtagNamePc string `description:"Pc端所有的分类名称"`
  80. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  81. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  82. IsNeedJump bool `description:"是否需要跳转链接地址"`
  83. IsTop bool `description:"是否置顶"`
  84. NumTop int `description:"置顶数量"`
  85. Source int `description:"来源 1:文章, 2:图表"`
  86. LabelList []*LabelList `description:"图表标签列表"`
  87. }
  88. type LabelList struct {
  89. PtagName string `description:"父类名称"`
  90. CtagName string `description:"子类名称"`
  91. }
  92. func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
  93. o := orm.NewOrm()
  94. sql := `SELECT COUNT(1) AS count
  95. FROM cygx_article AS a
  96. WHERE a.publish_status=1 `
  97. if condition != "" {
  98. sql += condition
  99. }
  100. err = o.Raw(sql, pars).QueryRow(&count)
  101. return
  102. }
  103. func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
  104. o := orm.NewOrm()
  105. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  106. FROM cygx_article AS a
  107. WHERE a.publish_status=1 `
  108. if condition != "" {
  109. sql += condition
  110. }
  111. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  112. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  113. return
  114. }
  115. func GetHomeListNew(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
  116. o := orm.NewOrm()
  117. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  118. FROM cygx_article AS a
  119. WHERE a.publish_status=1 `
  120. if condition != "" {
  121. sql += condition
  122. }
  123. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  124. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  125. return
  126. }
  127. // 获取产业报告列表
  128. func GetReportIndustrialList(condition string, pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
  129. o := orm.NewOrm()
  130. 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
  131. FROM
  132. cygx_article AS a
  133. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  134. WHERE
  135. a.publish_status = 1
  136. AND category_id IN (SELECT
  137. category_id
  138. FROM
  139. cygx_report_mapping
  140. WHERE
  141. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  142. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  143. AND a.is_class = 1
  144. AND man_g.industrial_management_id = ?` + condition
  145. sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? `
  146. _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items)
  147. return
  148. }
  149. func GetHomeListPublic(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
  150. o := orm.NewOrm()
  151. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  152. FROM cygx_article AS a
  153. WHERE a.publish_status=1 `
  154. if condition != "" {
  155. sql += condition
  156. }
  157. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  158. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  159. return
  160. }
  161. func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
  162. o := orm.NewOrm()
  163. sql := ` SELECT *
  164. FROM cygx_article AS a
  165. WHERE a.publish_status=1 `
  166. if condition != "" {
  167. sql += condition
  168. }
  169. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  170. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  171. return
  172. }