classify.go 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package models
  2. import (
  3. "eta/eta_hub/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "time"
  7. )
  8. type Classify struct {
  9. Id int `orm:"column(id);pk"`
  10. ClassifyName string `description:"分类名称"`
  11. Sort int `json:"-"`
  12. ParentId int `description:"父级分类id"`
  13. CreateTime time.Time `json:"-" description:"创建时间"`
  14. ModifyTime time.Time `json:"-" description:"修改时间"`
  15. Abstract string `json:"-" description:"栏目简介"`
  16. Descript string `json:"-" description:"分享描述"`
  17. ReportAuthor string `json:"-" description:"栏目作者"`
  18. AuthorDescript string `json:"-" description:"作者简介"`
  19. ColumnImgUrl string `json:"-" description:"栏目配图"`
  20. HeadImgUrl string `json:"-" description:"头部banner"`
  21. AvatarImgUrl string `json:"-" description:"头像"`
  22. ReportImgUrl string `json:"-" description:"报告配图"`
  23. HomeImgUrl string `json:"-" description:"首页配图"`
  24. ClassifyLabel string `description:"分类标签"`
  25. ShowType int `json:"-" description:"展示类型:1-列表 2-专栏"`
  26. HasTeleconference int `json:"-" description:"是否有电话会:0-否 1-是"`
  27. VipTitle string `json:"-" description:"研究员头衔"`
  28. IsShow int `json:"-" description:"是否在小程序显示:1-显示 0-隐藏"`
  29. YbFiccSort int `json:"-" description:"小程序FICC页排序"`
  30. YbFiccIcon string `json:"-" description:"小程序FICC页icon"`
  31. YbFiccPcIcon string `json:"-" description:"小程序PC端FICC页背景图"`
  32. YbIconUrl string `json:"-" description:"小程序已购页icon"`
  33. YbBgUrl string `json:"-" description:"小程序已购详情背景图"`
  34. YbListImg string `json:"-" description:"小程序研报列表封面图"`
  35. YbShareBgImg string `json:"-" description:"小程序研报详情分享背景图"`
  36. YbRightBanner string `json:"-" description:"Pc端详情页,右侧,报告合集背景图"`
  37. RelateTel int `json:"-" description:"是否在电话会中可选: 0-否; 1-是"`
  38. RelateVideo int `json:"-" description:"是否在路演视频中可选: 0-否; 1-是"`
  39. IsMassSend int `json:"-" description:"1:群发,0:非群发"`
  40. }
  41. type ClassifyListResp struct {
  42. List []*ClassifyList
  43. Paging *paging.PagingItem `description:"分页数据"`
  44. }
  45. type ClassifyList struct {
  46. Id int `orm:"column(id);pk"`
  47. ClassifyName string `description:"分类名称"`
  48. Sort int `description:"排序"`
  49. ParentId int `description:"父级分类id"`
  50. CreateTime time.Time `json:"-" description:"创建时间"`
  51. ModifyTime time.Time `json:"-" description:"修改时间"`
  52. Abstract string `description:"简介"`
  53. Descript string `description:"描述"`
  54. ClassifyLabel string `description:"分类标签"`
  55. ShowType int `json:"-" description:"展示类型:1-列表 2-专栏"`
  56. HasTeleconference int `json:"-" description:"是否有电话会:0-否 1-是"`
  57. IsShow int `json:"-" description:"是否在小程序显示:1-显示 0-隐藏"`
  58. YbFiccSort int `json:"-" description:"小程序FICC页排序"`
  59. YbFiccIcon string `json:"-" description:"小程序FICC页icon"`
  60. YbFiccPcIcon string `json:"-" description:"小程序PC端FICC页背景图"`
  61. YbIconUrl string `json:"-" description:"小程序已购页icon"`
  62. YbBgUrl string `json:"-" description:"小程序已购详情背景图"`
  63. YbListImg string `json:"-" description:"小程序研报列表封面图"`
  64. YbShareBgImg string `json:"-" description:"小程序研报详情分享背景图"`
  65. YbRightBanner string `json:"-" description:"Pc端详情页,右侧,报告合集背景图"`
  66. RelateTel int `json:"-" description:"是否在电话会中可选: 0-否; 1-是"`
  67. RelateVideo int `json:"-" description:"是否在路演视频中可选: 0-否; 1-是"`
  68. Child []*ClassifyItem
  69. //ClassifyMenuList []*ClassifyMenu
  70. }
  71. type ClassifyItem struct {
  72. Classify
  73. }
  74. func GetClassifyChildByParentIds(parentId []int, keyWord string) (items []*Classify, err error) {
  75. parentIdLen := len(parentId)
  76. if parentIdLen == 0 {
  77. return
  78. }
  79. o := orm.NewOrmUsingDB("rddp")
  80. sql := ``
  81. pars := make([]interface{}, 0)
  82. pars = append(pars, parentId)
  83. if keyWord != "" {
  84. sql = `SELECT * FROM classify WHERE parent_id IN (` + utils.GetOrmInReplace(parentIdLen) + `) AND classify_name LIKE ? ORDER BY create_time ASC `
  85. pars = append(pars, utils.GetLikeKeyword(keyWord))
  86. } else {
  87. sql = `SELECT * FROM classify WHERE parent_id IN (` + utils.GetOrmInReplace(parentIdLen) + `) ORDER BY create_time ASC `
  88. }
  89. _, err = o.Raw(sql, pars...).QueryRows(&items)
  90. return
  91. }