chart_permission.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ChartPermissionResp struct {
  6. ChartPermissionId int `description:"权限id"`
  7. PermissionName string `description:"权限名称"`
  8. }
  9. type ChartPermission struct {
  10. ChartPermissionId int `description:"权限id"`
  11. PermissionName string `description:"权限名称"`
  12. IsShowSustainable bool `description:"是否展示限免标签"`
  13. ImageUrlM string `description:"图片地址"`
  14. }
  15. type ChartPermissionItemResp struct {
  16. ChartPermissionId int `description:"权限id"`
  17. PermissionName string `description:"权限名称"`
  18. IsShowSustainable bool `description:"是否展示限免标签"`
  19. ImageUrlM string `description:"图片地址"`
  20. IsChoose bool `description:"是否选择"`
  21. MatchTypeName string `description:"匹配类型名称"`
  22. }
  23. type ChartPermissionListResp struct {
  24. List []*ChartPermissionResp
  25. CheckList []int `description:"权限"`
  26. }
  27. func GetChartPermissionReportAll(condition string) (items []*ChartPermissionResp, err error) {
  28. o := orm.NewOrmUsingDB("weekly_report")
  29. sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 AND permission_type!=2 ` + condition + ` ORDER BY sort ASC `
  30. _, err = o.Raw(sql).QueryRows(&items)
  31. return
  32. }
  33. func GetCategoryId(chartPermissionId int) (category_id string, err error) {
  34. o := orm.NewOrm()
  35. sql := ` SELECT GROUP_CONCAT(a.category_id) AS category_id
  36. FROM cygx_report_mapping AS a
  37. WHERE a.chart_permission_id=?
  38. GROUP BY a.chart_permission_id `
  39. err = o.Raw(sql, chartPermissionId).QueryRow(&category_id)
  40. return
  41. }
  42. func GetCategoryIdHome(chartPermissionId int) (category_id string, err error) {
  43. o := orm.NewOrm()
  44. sql := `SELECT GROUP_CONCAT(a.category_id) AS category_id
  45. FROM cygx_report_mapping AS a
  46. WHERE a.chart_permission_id=? AND a.is_summary = 1
  47. GROUP BY a.chart_permission_id `
  48. err = o.Raw(sql, chartPermissionId).QueryRow(&category_id)
  49. return
  50. }
  51. func GetChartPermissionById(chartPermissionId int) (item *ChartPermission, err error) {
  52. o := orm.NewOrmUsingDB("weekly_report")
  53. sql := `SELECT * FROM chart_permission WHERE chart_permission_id = ? `
  54. err = o.Raw(sql, chartPermissionId).QueryRow(&item)
  55. return
  56. }
  57. func GetChartPermissionListRai() (items []*ChartPermission, err error) {
  58. o := orm.NewOrmUsingDB("weekly_report")
  59. sql := `SELECT * FROM chart_permission WHERE product_id=2 ORDER BY sort ASC `
  60. _, err = o.Raw(sql).QueryRows(&items)
  61. return
  62. }