home.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. )
  6. type HomeArtAndChartListResp struct {
  7. Paging *paging.PagingItem
  8. List []*HomeArticle `description:"文章列表"`
  9. ChartList []*HomeChartListResp `description:"图表列表"`
  10. }
  11. type HomeArticle struct {
  12. ArticleId int `description:"文章id"`
  13. Title string `description:"标题"`
  14. TitleEn string `description:"英文标题 "`
  15. UpdateFrequency string `description:"更新周期"`
  16. CreateDate string `description:"创建时间"`
  17. PublishDate string `description:"发布时间"`
  18. Body string `description:"内容"`
  19. BodyHtml string `description:"内容带有HTML标签"`
  20. Abstract string `description:"摘要"`
  21. CategoryName string `description:"一级分类"`
  22. SubCategoryName string `description:"二级分类"`
  23. ExpertBackground string `description:"专家背景"`
  24. IsResearch bool `description:"是否属于研选"`
  25. Pv int `description:"PV"`
  26. ImgUrlPc string `description:"图片链接"`
  27. CategoryId string `description:"文章分类"`
  28. HttpUrl string `description:"文章链接跳转地址"`
  29. IsNeedJump bool `description:"是否需要跳转链接地址"`
  30. Source int `description:"来源 1:文章, 2:图表"`
  31. Annotation string `description:"核心观点"`
  32. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  33. MicroAudio *MicroAudioUnionList `description:"微路演音频"`
  34. List []*IndustrialManagementIdInt
  35. }
  36. type HomeChartListResp struct {
  37. ChartId int `description:"图表ID"`
  38. Title string `description:"标题"`
  39. TitleEn string `description:"英文标题 "`
  40. CreateDate string `description:"创建时间"`
  41. PtagName string `description:"父类名称"`
  42. CtagName string `description:"子类名称"`
  43. PtagNameTwo string `description:"父类名称"`
  44. CtagNameTwo string `description:"子类名称"`
  45. CtagNamePc string `description:"Pc端所有的分类名称"`
  46. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  47. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  48. IsNeedJump bool `description:"是否需要跳转链接地址"`
  49. IsTop bool `description:"是否置顶"`
  50. NumTop int `description:"置顶数量"`
  51. Source int `description:"来源 1:文章, 2:图表"`
  52. LabelList []*LabelList `description:"图表标签列表"`
  53. }
  54. type LabelList struct {
  55. PtagName string `description:"父类名称"`
  56. CtagName string `description:"子类名称"`
  57. }
  58. func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
  59. o := orm.NewOrm()
  60. sql := `SELECT COUNT(1) AS count
  61. FROM cygx_article AS a
  62. WHERE a.publish_status=1 `
  63. if condition != "" {
  64. sql += condition
  65. }
  66. err = o.Raw(sql, pars).QueryRow(&count)
  67. return
  68. }
  69. func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
  70. o := orm.NewOrm()
  71. sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
  72. FROM cygx_article AS a
  73. WHERE a.publish_status=1 `
  74. if condition != "" {
  75. sql += condition
  76. }
  77. sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
  78. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  79. return
  80. }
  81. func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeArticle, err error) {
  82. o := orm.NewOrm()
  83. sql := ` SELECT *
  84. FROM cygx_article AS a
  85. WHERE a.publish_status=1 `
  86. if condition != "" {
  87. sql += condition
  88. }
  89. sql += ` ORDER BY publish_date DESC LIMIT ?,? `
  90. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  91. return
  92. }