company_permission.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package company
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type ChartPermission struct {
  7. ChartPermissionId int `description:"权限id"`
  8. ChartPermissionName string `description:"权限名称(旧)"`
  9. PermissionName string `description:"权限名称"`
  10. Sort int `description:"排序"`
  11. Enabled int `description:"是否可用"`
  12. CreatedTime time.Time `description:"创建时间"`
  13. LastUpdatedTime time.Time `description:"最后更新时间"`
  14. TeleconferenceSort int `description:"电话会排序"`
  15. Remark string `description:"备注"`
  16. ClassifyName string `description:"分类"`
  17. PermissionType int `description:"1主观,2客观"`
  18. Checked bool `description:"选中状态"`
  19. }
  20. type PermissionSetItem struct {
  21. ChartPermissionId int `description:"权限id"`
  22. PermissionName string `description:"权限名称"`
  23. PermissionType int `description:"1主观,2客观"`
  24. Checked bool `description:"选中状态"`
  25. Child []*PermissionSetItem `description:"具体的主客观-方便前端的排版用的"`
  26. }
  27. type PermissionSetItemType struct {
  28. PermissionName string `description:"权限名称"`
  29. Checked bool `description:"选中状态"`
  30. CheckedMinate bool `description:"不确定状态"`
  31. NoClicking bool `description:"是否禁止点击"`
  32. Items []*PermissionLookItem
  33. }
  34. type PermissionSetList struct {
  35. ClassifyName string `description:"分类"`
  36. Items []*PermissionSetItem
  37. CheckList []int
  38. }
  39. type PermissionSetListType struct {
  40. ClassifyName string `description:"分类"`
  41. Items []*PermissionSetItemType
  42. CheckList []int
  43. }
  44. type PermissionSetResp struct {
  45. List []*PermissionSetList
  46. //ListUpgrade []*PermissionSetList `description:"升级权限列表"`
  47. ListType []*PermissionSetListType `description:"主观客观列表"`
  48. }
  49. func GetPermissionSetItems(productId int, classifyName string) (items []*PermissionSetItem, err error) {
  50. o := orm.NewOrmUsingDB("weekly")
  51. sql := ` SELECT * FROM chart_permission WHERE enabled=1 AND product_id=? AND classify_name=? AND permission_type=0 ORDER BY sort ASC `
  52. _, err = o.Raw(sql, productId, classifyName).QueryRows(&items)
  53. return
  54. }
  55. type PermissionLookItem struct {
  56. ChartPermissionId int `description:"权限id"`
  57. PermissionName string `description:"权限名称"`
  58. StartDate string `description:"权限开始日期"`
  59. EndDate string `description:"权限结束日期"`
  60. Status string `description:"'正式','试用','关闭'"`
  61. ExpireDay string `description:"到期天数"`
  62. ClassifyName string `description:"分类"`
  63. PermissionType int `description:"1主观,2客观"`
  64. PermissionTypeName string `description:"主观、客观"`
  65. Checked bool `description:"选中状态"`
  66. Remark string `description:"备注"`
  67. IsMerge bool `description:"是否合并行业, 给前端的标识, 暂时仅权益使用"`
  68. RaiBothHas bool `description:"权益-是否主客观都有"`
  69. IsUpgrade int `description:"是否升级,1是,0否"`
  70. Child []*PermissionLookItem `description:"子权限"`
  71. }
  72. type PermissionVarietyResp struct {
  73. List []*PermissionVarietyList
  74. }
  75. type PermissionVarietyItem struct {
  76. ChartPermissionId int `description:"权限id"`
  77. ClassifyName string `orm:"column(permission_name)" description:"权限名称"`
  78. }
  79. type PermissionVarietyList struct {
  80. ChartPermissionId int `description:"父级id"`
  81. ClassifyName string `description:"分类"`
  82. Items []*PermissionVarietyItem
  83. }
  84. func GetPermissionVarietyItems(productId int, classifyName string) (items []*PermissionVarietyItem, err error) {
  85. o := orm.NewOrmUsingDB("weekly")
  86. sql := ` SELECT * FROM chart_permission WHERE enabled=1 AND product_id=? AND classify_name=? GROUP BY permission_name ORDER BY sort ASC `
  87. _, err = o.Raw(sql, productId, classifyName).QueryRows(&items)
  88. return
  89. }
  90. // GetChartPermissionListById 根据权限id获取产品权限详情
  91. func GetChartPermissionListById(chartPermissionId int) (item *ChartPermission, err error) {
  92. o := orm.NewOrmUsingDB("weekly")
  93. sql := `SELECT * FROM chart_permission WHERE chart_permission_id =? `
  94. err = o.Raw(sql, chartPermissionId).QueryRow(&item)
  95. return
  96. }
  97. func GetParentIdFromGroup(gid int) (items *int, err error) {
  98. o := orm.NewOrm()
  99. sql := `SELECT parent_id FROM sys_group WHERE group_id=? `
  100. err = o.Raw(sql, gid).QueryRow(&items)
  101. return
  102. }
  103. func GetGroupNamesById(gid int) (items *string, err error) {
  104. o := orm.NewOrm()
  105. sql := `SELECT group_name FROM sys_group WHERE group_id=? `
  106. err = o.Raw(sql, gid).QueryRow(&items)
  107. return
  108. }