home.go 9.0 KB

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