chart_permission.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package models
  2. import (
  3. "eta/eta_mini_crm/utils"
  4. "time"
  5. "github.com/beego/beego/v2/client/orm"
  6. )
  7. type ChartPermission struct {
  8. ChartPermissionId int `orm:"column(chart_permission_id);pk" description:"问题ID" json:"chart_permission_id"`
  9. ChartPermissionName string `description:"名称" json:"chart_permission_name"`
  10. PermissionName string `description:"权限名" json:"permission_name"`
  11. Sort int `description:"排序" json:"sort"`
  12. Enabled int `description:"是否可用" json:"enabled"`
  13. CreatedTime time.Time `description:"创建时间" json:"created_time"`
  14. LastUpdatedTime time.Time `description:"更新时间" json:"last_updated_time"`
  15. TeleconferenceSort int `description:"电话会类型排序" json:"teleconference_sort"`
  16. Remark string `description:"备注" json:"remark"`
  17. ClassifyName string `description:"分类名称" json:"classify_name"`
  18. ProductName string `description:"产品名称" json:"product_name"`
  19. ProductId int `description:"产品ID" json:"product_id"`
  20. ImageURL string `orm:"column(image_url);" description:"图片地址" json:"image_url"`
  21. ShowType int `description:"1:查研观向小程序展示" json:"show_type"`
  22. IsOther int `description:"是否是其他,用于查研观向小程序后台展示" json:"is_other"`
  23. IsReport int `description:"是否是报告,用于查研观向小程序前台报告展示" json:"is_report"`
  24. CygxAuth int `description:"是否是权限,用于查研观向小程序前台权限校验" json:"cygx_auth"`
  25. PermissionType int `description:"1主观,2客观" json:"permission_type"`
  26. YbImgUrl string `description:"研报小程序报告列表icon" json:"yb_img_url"`
  27. ProductPermissionName string `description:"种类权限名称" json:"product_permission_name"`
  28. PriceDrivenState int `description:"品种价格驱动开启状态 0-关闭 1-开启" json:"price_driven_state"`
  29. ImageUrlM string `description:"图片地址(查研观向移动端)" json:"image_url_m"`
  30. ParentId int `description:"父级权限id" json:"parent_id"`
  31. IsPublic int `description:"是否是公有权限1:公有权限,0私有权限" json:"is_public"`
  32. }
  33. type ChartPermissionList struct {
  34. ChartPermissionId int `orm:"column(chart_permission_id);pk" description:"问题ID" json:"chart_permission_id"`
  35. ChartPermissionName string `description:"名称" json:"chart_permission_name"`
  36. PermissionName string `description:"权限名" json:"permission_name"`
  37. Sort int `description:"排序" json:"sort"`
  38. Enabled int `description:"是否可用" json:"enabled"`
  39. CreatedTime time.Time `description:"创建时间" json:"created_time"`
  40. LastUpdatedTime time.Time `description:"更新时间" json:"last_updated_time"`
  41. TeleconferenceSort int `description:"电话会类型排序" json:"teleconference_sort"`
  42. Remark string `description:"备注" json:"remark"`
  43. ClassifyName string `description:"分类名称" json:"classify_name"`
  44. ProductName string `description:"产品名称" json:"product_name"`
  45. ProductId int `description:"产品ID" json:"product_id"`
  46. ImageURL string `orm:"column(image_url);" description:"图片地址" json:"image_url"`
  47. ShowType int `description:"1:查研观向小程序展示" json:"show_type"`
  48. IsOther int `description:"是否是其他,用于查研观向小程序后台展示" json:"is_other"`
  49. IsReport int `description:"是否是报告,用于查研观向小程序前台报告展示" json:"is_report"`
  50. CygxAuth int `description:"是否是权限,用于查研观向小程序前台权限校验" json:"cygx_auth"`
  51. PermissionType int `description:"1主观,2客观" json:"permission_type"`
  52. YbImgUrl string `description:"研报小程序报告列表icon" json:"yb_img_url"`
  53. ProductPermissionName string `description:"种类权限名称" json:"product_permission_name"`
  54. PriceDrivenState int `description:"品种价格驱动开启状态 0-关闭 1-开启" json:"price_driven_state"`
  55. ImageUrlM string `description:"图片地址(查研观向移动端)" json:"image_url_m"`
  56. ParentId int `description:"父级权限id" json:"parent_id"`
  57. IsPublic int `description:"是否是公有权限1:公有权限,0私有权限" json:"is_public"`
  58. Child []*ChartPermissionList `description:"子权限"`
  59. }
  60. type ChartPermissionView struct {
  61. ParentName string `description:"父权限名称" json:"parent_name"`
  62. PermissionName string `description:"权限名" json:"permission_name"`
  63. }
  64. type ChartPermissionListTree struct {
  65. ChartPermissionId int `description:"权限ID"`
  66. PermissionName string `description:"权限名"`
  67. ParentId int `description:"父权限ID"`
  68. IsPublic int `description:"是否是公有权限"`
  69. PublicChild []*ChartPermissionListTree `description:"公有权限"`
  70. PrivateChild []*ChartPermissionListTree `description:"私有权限"`
  71. }
  72. func GetChartPermissionListByCondition(condition string, pars []interface{}) (items []*ChartPermission, err error) {
  73. o := orm.NewOrmUsingDB("rddp")
  74. sql := `SELECT * FROM chart_permission WHERE enabled=1 `
  75. if condition != "" {
  76. sql += condition
  77. }
  78. _, err = o.Raw(sql, pars...).QueryRows(items)
  79. return
  80. }
  81. func GetChartPermissionListByIds(chartPermissionIds []int) (items []*ChartPermissionView, err error) {
  82. if len(chartPermissionIds) == 0 {
  83. return
  84. }
  85. o := orm.NewOrmUsingDB("rddp")
  86. sql := `SELECT c.permission_name AS permission_name, lc.permission_name AS parent_name FROM chart_permission c
  87. LEFT JOIN chart_permission lc
  88. ON c.parent_id=lc.chart_permission_id
  89. WHERE c.chart_permission_id in (` + utils.GetOrmReplaceHolder(len(chartPermissionIds)) + `) `
  90. _, err = o.Raw(sql, chartPermissionIds).QueryRows(&items)
  91. return
  92. }
  93. func GetChartPermissionList() (items []*ChartPermissionListTree, err error) {
  94. o := orm.NewOrmUsingDB("rddp")
  95. sql := `SELECT * FROM chart_permission WHERE enabled=1 AND product_id=1 ORDER BY sort, chart_permission_id ASC`
  96. _, err = o.Raw(sql).QueryRows(&items)
  97. return
  98. }
  99. func GetChartPermissionByParentId(parentId int) (items []*ChartPermissionList, err error) {
  100. o := orm.NewOrmUsingDB("rddp")
  101. sql := `SELECT * FROM chart_permission WHERE enabled=1 AND chart_permission_id=?`
  102. _, err = o.Raw(sql, parentId).QueryRows(&items)
  103. return
  104. }