classify.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. Enabled int `description:"是否可用,1可用,0禁用"`
  41. Level int `description:"层级"`
  42. HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
  43. }
  44. type ClassifyListResp struct {
  45. List []*ClassifyList
  46. Paging *paging.PagingItem `description:"分页数据"`
  47. }
  48. type ClassifyList struct {
  49. Id int `orm:"column(id);pk"`
  50. ClassifyName string `description:"分类名称"`
  51. Sort int `description:"排序"`
  52. ParentId int `description:"父级分类id"`
  53. CreateTime time.Time `json:"-" description:"创建时间"`
  54. ModifyTime time.Time `json:"-" description:"修改时间"`
  55. Abstract string `description:"简介"`
  56. Descript string `description:"描述"`
  57. ClassifyLabel string `description:"分类标签"`
  58. ShowType int `json:"-" description:"展示类型:1-列表 2-专栏"`
  59. HasTeleconference int `json:"-" description:"是否有电话会:0-否 1-是"`
  60. IsShow int `json:"-" description:"是否在小程序显示:1-显示 0-隐藏"`
  61. YbFiccSort int `json:"-" description:"小程序FICC页排序"`
  62. YbFiccIcon string `json:"-" description:"小程序FICC页icon"`
  63. YbFiccPcIcon string `json:"-" description:"小程序PC端FICC页背景图"`
  64. YbIconUrl string `json:"-" description:"小程序已购页icon"`
  65. YbBgUrl string `json:"-" description:"小程序已购详情背景图"`
  66. YbListImg string `json:"-" description:"小程序研报列表封面图"`
  67. YbShareBgImg string `json:"-" description:"小程序研报详情分享背景图"`
  68. YbRightBanner string `json:"-" description:"Pc端详情页,右侧,报告合集背景图"`
  69. RelateTel int `json:"-" description:"是否在电话会中可选: 0-否; 1-是"`
  70. RelateVideo int `json:"-" description:"是否在路演视频中可选: 0-否; 1-是"`
  71. Child []*ClassifyItem
  72. //ClassifyMenuList []*ClassifyMenu
  73. }
  74. type ClassifyItem struct {
  75. Classify
  76. }
  77. func GetClassifyChildByParentIds(parentId []int, keyWord string) (items []*Classify, err error) {
  78. parentIdLen := len(parentId)
  79. if parentIdLen == 0 {
  80. return
  81. }
  82. o := orm.NewOrmUsingDB("rddp")
  83. sql := ``
  84. pars := make([]interface{}, 0)
  85. pars = append(pars, parentId)
  86. if keyWord != "" {
  87. sql = `SELECT * FROM classify WHERE parent_id IN (` + utils.GetOrmInReplace(parentIdLen) + `) AND classify_name LIKE ? ORDER BY create_time ASC `
  88. pars = append(pars, utils.GetLikeKeyword(keyWord))
  89. } else {
  90. sql = `SELECT * FROM classify WHERE parent_id IN (` + utils.GetOrmInReplace(parentIdLen) + `) ORDER BY create_time ASC `
  91. }
  92. _, err = o.Raw(sql, pars...).QueryRows(&items)
  93. return
  94. }
  95. type ClassifyListV2Resp struct {
  96. List []*ClassifyListV2
  97. }
  98. type ClassifyListV2 struct {
  99. Id int `orm:"column(id);pk"`
  100. ClassifyName string `description:"分类名称"`
  101. Sort int `description:"排序"`
  102. ParentId int `description:"父级分类id"`
  103. CreateTime time.Time `description:"创建时间"`
  104. ModifyTime time.Time `description:"修改时间"`
  105. Abstract string `description:"简介"`
  106. Descript string `description:"描述"`
  107. ClassifyLabel string `description:"分类标签"`
  108. ShowType int `description:"展示类型:1-列表 2-专栏"`
  109. HasTeleconference int `description:"是否有电话会:0-否 1-是"`
  110. IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"`
  111. YbFiccSort int `description:"小程序FICC页排序"`
  112. YbFiccIcon string `description:"小程序FICC页icon"`
  113. YbFiccPcIcon string `description:"小程序PC端FICC页背景图"`
  114. YbIconUrl string `description:"小程序已购页icon"`
  115. YbBgUrl string `description:"小程序已购详情背景图"`
  116. YbListImg string `description:"小程序研报列表封面图"`
  117. YbShareBgImg string `description:"小程序研报详情分享背景图"`
  118. YbRightBanner string `description:"Pc端详情页,右侧,报告合集背景图"`
  119. RelateTel int `description:"是否在电话会中可选: 0-否; 1-是"`
  120. RelateVideo int `description:"是否在路演视频中可选: 0-否; 1-是"`
  121. Enabled int `description:"是否可用,1可用,0禁用"`
  122. Child []*ClassifyListV2
  123. ClassifyMenuId int `description:"二级分类-子目录ID"`
  124. //ClassifyMenuList []*ClassifyMenu
  125. //ChartPermissionIdList []int `description:"绑定的权限ID"`
  126. Level int `description:"层级"`
  127. HasChild int `description:"是否有子级别,0:下面没有子分类,1:下面有子分类;默认:0"`
  128. }
  129. // GetClassifyListByParentIdList
  130. // @Description: 获取分类列表
  131. // @author: Roc
  132. // @datetime 2024-06-19 09:49:33
  133. // @param keyWord string
  134. // @param enabled int
  135. // @return items []*ClassifyList
  136. // @return err error
  137. func GetClassifyListByParentIdList(parentClassifyIdList []int) (items []*ClassifyListV2, err error) {
  138. num := len(parentClassifyIdList)
  139. if num <= 0 {
  140. return
  141. }
  142. sql := `SELECT * FROM classify WHERE id in (` + utils.GetOrmInReplace(num) + `) ORDER BY sort ASC, create_time ASC`
  143. o := orm.NewOrmUsingDB("rddp")
  144. _, err = o.Raw(sql, parentClassifyIdList).QueryRows(&items)
  145. return
  146. }