chart_permission.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. package chart_permission
  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. ParentId int `description:"父级权限id"`
  28. IsPublic int `description:"是否是公有权限1:公有权限,0私有权限"`
  29. }
  30. // GetChartPermissionById 主键获取权限
  31. func GetChartPermissionById(permissionId int) (item *ChartPermission, err error) {
  32. o := orm.NewOrm()
  33. sql := `SELECT * FROM chart_permission WHERE chart_permission_id = ? LIMIT 1`
  34. err = o.Raw(sql, permissionId).QueryRow(&item)
  35. return
  36. }
  37. // Update 更新
  38. func (chartPermissionInfo *ChartPermission) Update(cols []string) (err error) {
  39. o := orm.NewOrm()
  40. _, err = o.Update(chartPermissionInfo, cols...)
  41. return
  42. }
  43. // YbChartPermissionFirst 研报一级品种分类
  44. type YbChartPermissionFirst struct {
  45. Id int
  46. ClassifyName string `description:"权限一级分类名称,与chart_permission的classify_name一致"`
  47. YbIndexShow int `description:"是否展示在研报小程序首页页面 1-展示;0-不展示"`
  48. YbIndexName string `description:"研报小程序首页简称"`
  49. YbIndexSort string `description:"研报小程序首页排序"`
  50. YbIndexIcon string `description:"研报小程序首页图标地址"`
  51. }
  52. // GetYbChartPermissionFirst 获取研报一级品种分类
  53. func GetYbChartPermissionFirst() (list []*YbChartPermissionFirst, err error) {
  54. o := orm.NewOrm()
  55. sql := `SELECT * FROM chart_permission_first ORDER BY yb_index_sort ASC`
  56. _, err = o.Raw(sql).QueryRows(&list)
  57. return
  58. }
  59. // GetFiccPermissionExceptTactic 获取除了市场策略外的ficc权限
  60. func GetFiccPermissionExceptTactic() (items []*ChartPermission, err error) {
  61. o := orm.NewOrm()
  62. sql := `SELECT * FROM chart_permission WHERE enabled = 1 AND permission_type = 0 AND product_id = 1 and classify_name != '市场策略' ORDER BY sort ASC`
  63. _, err = o.Raw(sql).QueryRows(&items)
  64. return
  65. }
  66. // GetPermissionFirstByProductId 获取一级品种权限
  67. func GetPermissionFirstByProductId(productId int) (items []*ChartPermission, err error) {
  68. o := orm.NewOrm()
  69. sql := `SELECT * FROM chart_permission WHERE enabled = 1 AND product_id = ? AND parent_id = 0 AND permission_type = 0 and classify_name != '市场策略' ORDER BY sort ASC`
  70. _, err = o.Raw(sql, productId).QueryRows(&items)
  71. return
  72. }
  73. // GetPermissionSecondByProductId 获取二级品种权限
  74. func GetPermissionSecondByProductId(productId int) (items []*ChartPermission, err error) {
  75. o := orm.NewOrm()
  76. sql := `SELECT * FROM chart_permission WHERE enabled = 1 AND product_id = ? AND parent_id > 0 AND permission_type = 0 and classify_name != '市场策略' ORDER BY sort ASC`
  77. _, err = o.Raw(sql, productId).QueryRows(&items)
  78. return
  79. }
  80. // GetYbChartPermissionFirstByName 根据分类名称获取一级分类
  81. func GetYbChartPermissionFirstByName(classifyName string) (item *YbChartPermissionFirst, err error) {
  82. o := orm.NewOrm()
  83. sql := `SELECT * FROM chart_permission_first WHERE classify_name = ? LIMIT 1`
  84. err = o.Raw(sql, classifyName).QueryRow(&item)
  85. return
  86. }
  87. // GetChartPermissionById 主键获取权限
  88. func GetChartPermissionByRemark(remark string) (item *ChartPermission, err error) {
  89. o := orm.NewOrm()
  90. sql := `SELECT * FROM chart_permission WHERE remark = ? and parent_id > 0 LIMIT 1`
  91. err = o.Raw(sql, remark).QueryRow(&item)
  92. return
  93. }
  94. // GetChartPermissionByIds 主键获取权限
  95. func GetChartPermissionByIds(permissionIds []string) (list []*ChartPermission, err error) {
  96. qb, _ := orm.NewQueryBuilder("mysql")
  97. // 构建查询对象
  98. qb.Select("*").From("chart_permission").
  99. Where("chart_permission_id").In(permissionIds...)
  100. // 导出 SQL 语句
  101. sql := qb.String()
  102. // 执行 SQL 语句
  103. o := orm.NewOrm()
  104. _, err = o.Raw(sql).QueryRows(&list)
  105. return
  106. }
  107. // GetChartPermissionByIds 主键获取权限
  108. func GetChartPermissionByNames(permissionNames []string) (list []*ChartPermission, err error) {
  109. qb, _ := orm.NewQueryBuilder("mysql")
  110. // 构建查询对象
  111. qb.Select("*").From("chart_permission").
  112. Where("chart_permission_name").In(permissionNames...)
  113. // 导出 SQL 语句
  114. sql := qb.String()
  115. // 执行 SQL 语句
  116. o := orm.NewOrm()
  117. _, err = o.Raw(sql).QueryRows(&list)
  118. return
  119. }
  120. // GetChartPermissionList 获取品种权限列表
  121. func GetChartPermissionList() (list []*ChartPermission, err error) {
  122. o := orm.NewOrm()
  123. sql := `SELECT * FROM chart_permission where parent_id > 0 `
  124. _, err = o.Raw(sql).QueryRows(&list)
  125. return
  126. }
  127. // 获取权益主观权限
  128. func GetChartPermissionListRaiSubjectivity() (items []*ChartPermission, err error) {
  129. o := orm.NewOrm()
  130. sql := `SELECT * FROM chart_permission WHERE product_id=2 AND permission_type = 1 and parent_id > 0 ORDER BY sort ASC `
  131. _, err = o.Raw(sql).QueryRows(&items)
  132. return
  133. }