home.go 8.2 KB

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