chart_permission.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ChartPermission 报告权限表
  7. type ChartPermission struct {
  8. ChartPermissionId int `orm:"column(chart_permission_id);pk" description:"问题ID"`
  9. ChartPermissionName string `description:"名称"`
  10. PermissionName string `description:"权限名"`
  11. Sort int `description:"排序"`
  12. Enabled int `description:"是否可用"`
  13. CreatedTime time.Time `description:"创建时间"`
  14. LastUpdatedTime time.Time `description:"更新时间"`
  15. TeleconferenceSort int `description:"电话会类型排序"`
  16. Remark string `description:"备注"`
  17. ClassifyName string `description:"分类名称"`
  18. ProductName string `description:"产品名称"`
  19. ProductID int `description:"产品ID"`
  20. ImageURL string `description:"图片地址"`
  21. ShowType int `description:"1:查研观向小程序展示"`
  22. IsOther int `description:"是否是其他,用于查研观向小程序后台展示"`
  23. IsReport int `description:"是否是报告,用于查研观向小程序前台报告展示"`
  24. CygxAuth int `description:"是否是权限,用于查研观向小程序前台权限校验"`
  25. YbImgUrl string `description:"研报小程序报告列表icon"`
  26. PriceDrivenState int `description:"品种价格驱动开启状态 0-关闭 1-开启"`
  27. }
  28. // GetChartPermissionById 主键获取权限
  29. func GetChartPermissionById(permissionId int) (item *ChartPermission, err error) {
  30. o := orm.NewOrm()
  31. sql := `SELECT * FROM chart_permission WHERE chart_permission_id = ? LIMIT 1`
  32. err = o.Raw(sql, permissionId).QueryRow(&item)
  33. return
  34. }
  35. // Update 更新
  36. func (chartPermissionInfo *ChartPermission) Update(cols []string) (err error) {
  37. o := orm.NewOrm()
  38. _, err = o.Update(chartPermissionInfo, cols...)
  39. return
  40. }
  41. // YbChartPermissionFirst 研报一级品种分类
  42. type YbChartPermissionFirst struct {
  43. Id int
  44. ClassifyName string `description:"权限一级分类名称,与chart_permission的classify_name一致"`
  45. YbIndexShow int `description:"是否展示在研报小程序首页页面 1-展示;0-不展示"`
  46. YbIndexName string `description:"研报小程序首页简称"`
  47. YbIndexSort string `description:"研报小程序首页排序"`
  48. YbIndexIcon string `description:"研报小程序首页图标地址"`
  49. }
  50. // GetYbChartPermissionFirst 获取研报一级品种分类
  51. func GetYbChartPermissionFirst() (list []*YbChartPermissionFirst, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT * FROM chart_permission_first ORDER BY yb_index_sort ASC`
  54. _, err = o.Raw(sql).QueryRows(&list)
  55. return
  56. }
  57. // GetPermissionByProductIdAndClassifyName 获取子分类
  58. func GetPermissionByProductIdAndClassifyName(productId int, classifyName string) (items []*ChartPermission, err error) {
  59. o := orm.NewOrm()
  60. sql := `SELECT * FROM chart_permission WHERE enabled = 1 AND product_id = ? AND classify_name = ? AND permission_type = 0 ORDER BY sort ASC`
  61. _, err = o.Raw(sql, productId, classifyName).QueryRows(&items)
  62. return
  63. }
  64. // GetYbChartPermissionFirstByName 根据分类名称获取一级分类
  65. func GetYbChartPermissionFirstByName(classifyName string) (item *YbChartPermissionFirst, err error) {
  66. o := orm.NewOrm()
  67. sql := `SELECT * FROM chart_permission_first WHERE classify_name = ? LIMIT 1`
  68. err = o.Raw(sql, classifyName).QueryRow(&item)
  69. return
  70. }
  71. // GetChartPermissionByIds 主键获取权限
  72. func GetChartPermissionByIds(permissionIds []string) (list []*ChartPermission, err error) {
  73. qb, _ := orm.NewQueryBuilder("mysql")
  74. // 构建查询对象
  75. qb.Select("*").From("chart_permission").
  76. Where("chart_permission_id").In(permissionIds...)
  77. // 导出 SQL 语句
  78. sql := qb.String()
  79. // 执行 SQL 语句
  80. o := orm.NewOrm()
  81. _, err = o.Raw(sql).QueryRows(&list)
  82. return
  83. }
  84. // GetChartPermissionList 获取品种权限列表
  85. func GetChartPermissionList() (list []*ChartPermission, err error) {
  86. o := orm.NewOrm()
  87. sql := `SELECT * FROM chart_permission `
  88. _, err = o.Raw(sql).QueryRows(&list)
  89. return
  90. }
  91. // 获取权益主观权限
  92. func GetChartPermissionListRaiSubjectivity() (items []*ChartPermission, err error) {
  93. o := orm.NewOrm()
  94. sql := `SELECT * FROM chart_permission WHERE product_id=2 AND permission_type = 1 ORDER BY sort ASC `
  95. _, err = o.Raw(sql).QueryRows(&items)
  96. return
  97. }