home.go 8.9 KB

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