home.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. Cover string `description:"封面图片"`
  71. BodyHighlight []string `description:"搜索高亮展示结果"`
  72. List []*IndustrialManagementIdInt
  73. }
  74. type HomeChartListResp struct {
  75. ChartId int `description:"图表ID"`
  76. Title string `description:"标题"`
  77. TitleEn string `description:"英文标题 "`
  78. CreateDate string `description:"创建时间"`
  79. PtagName string `description:"父类名称"`
  80. CtagName string `description:"子类名称"`
  81. PtagNameTwo string `description:"父类名称"`
  82. CtagNameTwo string `description:"子类名称"`
  83. CtagNamePc string `description:"Pc端所有的分类名称"`
  84. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  85. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  86. IsNeedJump bool `description:"是否需要跳转链接地址"`
  87. IsTop bool `description:"是否置顶"`
  88. NumTop int `description:"置顶数量"`
  89. Source int `description:"来源 1:文章, 2:图表"`
  90. LabelList []*LabelList `description:"图表标签列表"`
  91. }
  92. type LabelList struct {
  93. PtagName string `description:"父类名称"`
  94. CtagName string `description:"子类名称"`
  95. }
  96. func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
  97. o := orm.NewOrm()
  98. sql := `SELECT COUNT(1) AS count
  99. FROM cygx_article AS a
  100. WHERE a.publish_status=1 `
  101. if condition != "" {
  102. sql += condition
  103. }
  104. err = o.Raw(sql, pars).QueryRow(&count)
  105. return
  106. }
  107. func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
  108. o := orm.NewOrm()
  109. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  110. FROM cygx_article AS a
  111. WHERE a.publish_status=1 `
  112. if condition != "" {
  113. sql += condition
  114. }
  115. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  116. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  117. return
  118. }
  119. func GetHomeListNew(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
  120. o := orm.NewOrm()
  121. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  122. FROM cygx_article AS a
  123. WHERE a.publish_status=1 `
  124. if condition != "" {
  125. sql += condition
  126. }
  127. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  128. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  129. return
  130. }
  131. // 获取产业报告列表
  132. func GetReportIndustrialList(condition string, pars []interface{}, categoryId, industrialManagementId, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
  133. o := orm.NewOrm()
  134. 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
  135. FROM
  136. cygx_article AS a
  137. INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
  138. WHERE
  139. a.publish_status = 1
  140. AND category_id IN (SELECT
  141. category_id
  142. FROM
  143. cygx_report_mapping
  144. WHERE
  145. chart_permission_id = any( SELECT chart_permission_id FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` )
  146. AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ` + strconv.Itoa(categoryId) + ` ) )
  147. AND a.is_class = 1
  148. AND man_g.industrial_management_id = ?` + condition
  149. sql += ` GROUP BY a.article_id ORDER BY publish_date DESC LIMIT ?,? `
  150. _, err = o.Raw(sql, pars, industrialManagementId, startSize, pageSize).QueryRows(&items)
  151. return
  152. }
  153. func GetHomeListPublic(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
  154. o := orm.NewOrm()
  155. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  156. FROM cygx_article AS a
  157. WHERE a.publish_status=1 `
  158. if condition != "" {
  159. sql += condition
  160. }
  161. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  162. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  163. return
  164. }
  165. func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
  166. o := orm.NewOrm()
  167. sql := ` SELECT *
  168. FROM cygx_article AS a
  169. WHERE a.publish_status=1 `
  170. if condition != "" {
  171. sql += condition
  172. }
  173. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  174. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  175. return
  176. }