home.go 8.8 KB

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