rule.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package user
  2. import (
  3. "go-common/library/time"
  4. )
  5. // rules
  6. const (
  7. UserView = "USER_VIEW"
  8. UserEdit = "USER_EDIT"
  9. UserAudit = "USER_AUDIT"
  10. EcodeView = "ECODE_VIEW"
  11. EcodeEdit = "ECODE_EDIT"
  12. DatabusKeyView = "DATABUS_KEY_VIEW"
  13. DatabusKeyEdit = "DATABUS_KEY_EDIT"
  14. DatabusGroupView = "DATABUS_GROUP_VIEW"
  15. DatabusGroupEdit = "DATABUS_GROUP_EDIT"
  16. DatabusTopicView = "DATABUS_TOPIC_VIEW"
  17. DatabusTopicEdit = "DATABUS_TOPIC_EDIT"
  18. DatabusNotifyView = "DATABUS_NOTIFY_VIEW"
  19. DatabusNotifyEdit = "DATABUS_NOTIFY_EDIT"
  20. DatabusGroupApply = "DATABUS_GROUP_APPLY"
  21. DapperView = "DAPPER_VIEW"
  22. CanalView = "CANAL_VIEW"
  23. CanalEdit = "CANAL_EDIT"
  24. ConfigView = "CONFIG_VIEW"
  25. ConfigSearchView = "CONFIG_SEARCH_VIEW"
  26. ConfigPublicView = "CONFIG_PUBLIC_VIEW"
  27. DiscoveryView = "DISCOVERY_VIEW"
  28. PerformanceManager = "PERFORMANCE_MANAGER"
  29. AppView = "APP_VIEW"
  30. AppEdit = "APP_EDIT"
  31. AppAuthView = "APP_AUTH_VIEW"
  32. AppCallerSearch = "APP_CALLER_SEARCH"
  33. NeedVerify = "NEED_VERIFY"
  34. PlatformSearchView = "PLATFORM_SEARCH_VIEW"
  35. PlatformReplyView = "PLATFORM_REPLY_VIEW"
  36. PlatformTagView = "PLATFORM_TAG_VIEW"
  37. CacheOpsView = "CACHE_OPS_VIEW"
  38. OpenView = "OPEN_VIEW"
  39. BFSView = "BFS_VIEW"
  40. BFSEdit = "BFS_EDIT"
  41. )
  42. //PermitType value
  43. const (
  44. PermitDefault = iota
  45. PermitAuth
  46. PermitSuper
  47. )
  48. // PermitType permit type
  49. type PermitType int
  50. // Permission descript modules and rules
  51. type Permission struct {
  52. Name string
  53. Permit PermitType
  54. Des string
  55. }
  56. // rules
  57. var (
  58. Rules = map[string]*Permission{
  59. UserView: {Name: "UserView", Permit: PermitSuper, Des: "用户查看"},
  60. UserEdit: {Name: "UserEdit", Permit: PermitSuper, Des: "用户管理"},
  61. UserAudit: {Name: "UserAudit", Permit: PermitSuper, Des: "权限审核"},
  62. EcodeView: {Name: "EcodeView", Permit: PermitDefault, Des: "错误码查看"},
  63. EcodeEdit: {Name: "EcodeEdit", Permit: PermitDefault, Des: "错误码编辑"},
  64. DatabusKeyView: {Name: "DatabusKeyView", Permit: PermitDefault, Des: "Key查看"},
  65. DatabusKeyEdit: {Name: "DatabusKeyEdit", Permit: PermitAuth, Des: "Key编辑"},
  66. DatabusGroupView: {Name: "DatabusGroupView", Permit: PermitDefault, Des: "Group查看"},
  67. DatabusGroupEdit: {Name: "DatabusGroupEdit", Permit: PermitAuth, Des: "Group修改"},
  68. DatabusTopicView: {Name: "DatabusTopicView", Permit: PermitDefault, Des: "Topic查看"},
  69. DatabusTopicEdit: {Name: "DatabusTopicEdit", Permit: PermitAuth, Des: "Topic编辑"},
  70. DatabusNotifyView: {Name: "DatabusNotifyView", Permit: PermitDefault, Des: "Notify查看"},
  71. DatabusNotifyEdit: {Name: "DatabusNotifyEdit", Permit: PermitAuth, Des: "Notify编辑"},
  72. DatabusGroupApply: {Name: "DatabusGroupApply", Permit: PermitAuth, Des: "Group审核"},
  73. DapperView: {Name: "DapperView", Permit: PermitDefault, Des: "Dapper查询"},
  74. CanalView: {Name: "CanalView", Permit: PermitDefault, Des: "Canal查看"},
  75. CanalEdit: {Name: "CanalEdit", Permit: PermitAuth, Des: "Canal编辑"},
  76. ConfigView: {Name: "ConfigView", Permit: PermitDefault, Des: "配置列表查看"},
  77. ConfigSearchView: {Name: "ConfigSearchView", Permit: PermitAuth, Des: "搜索列表查看"},
  78. ConfigPublicView: {Name: "ConfigPublicView", Permit: PermitDefault, Des: "公共配置查看"},
  79. DiscoveryView: {Name: "DiscoveryView", Permit: PermitDefault, Des: "Discovery查看"},
  80. AppView: {Name: "AppView", Permit: PermitDefault, Des: "APP查看"},
  81. AppEdit: {Name: "AppEdit", Permit: PermitAuth, Des: "APP编辑"},
  82. AppAuthView: {Name: "AppAuthView", Permit: PermitAuth, Des: "APP鉴权查看"},
  83. AppCallerSearch: {Name: "AppCallerSearch", Permit: PermitAuth, Des: "APP调用方查询"},
  84. PlatformSearchView: {Name: "PlatformSearchView", Permit: PermitAuth, Des: "平台搜索"},
  85. PlatformReplyView: {Name: "PlatformReplyView", Permit: PermitAuth, Des: "平台评论"},
  86. PlatformTagView: {Name: "PlatformTagView", Permit: PermitAuth, Des: "Tag"},
  87. CacheOpsView: {Name: "CacheOpsView", Permit: PermitAuth, Des: "overlord缓存集群管理"},
  88. NeedVerify: {Name: "NeedVerify", Permit: PermitSuper, Des: "需求建议审核"},
  89. OpenView: {Name: "OpenView", Permit: PermitAuth, Des: "open鉴权查看"},
  90. PerformanceManager: {Name: "PerformanceManager", Permit: PermitDefault, Des: "性能管理"},
  91. BFSView: {Name: "BFSView", Permit: PermitAuth, Des: "BFS查看"},
  92. BFSEdit: {Name: "BFSEdit", Permit: PermitAuth, Des: "BFS编辑"},
  93. }
  94. )
  95. // TableName case tablename
  96. func (*Rule) TableName() string {
  97. return "user_rule"
  98. }
  99. // TableName case tablename
  100. func (*Apply) TableName() string {
  101. return "user_apply"
  102. }
  103. // Rule rule model
  104. type Rule struct {
  105. ID int64 `gorm:"column:id" json:"id"`
  106. UserID int64 `gorm:"column:user_id" json:"user_id"`
  107. Rule string `gorm:"column:rule" json:"rule"`
  108. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  109. Mtime time.Time `gorm:"column:mtime" json:"-"`
  110. }
  111. // Apply user apply
  112. type Apply struct {
  113. ID int64 `gorm:"column:id" json:"id"`
  114. UserID int64 `gorm:"column:user_id" json:"user_id" params:"user_id"`
  115. Rules string `gorm:"column:rules" json:"rules" params:"rules"`
  116. Admin string `gorm:"column:admin" json:"admin" params:"admin"`
  117. Status int8 `gorm:"column:status" json:"status" `
  118. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  119. Mtime time.Time `gorm:"column:mtime" json:"-"`
  120. }
  121. // Applies ...
  122. type Applies struct {
  123. ID int64 `gorm:"column:id" json:"id"`
  124. UserID int64 `gorm:"column:user_id" json:"user_id"`
  125. UserName string `gorm:"column:username" json:"username"`
  126. Rules string `gorm:"column:rules" json:"rules"`
  127. Status string `gorm:"column:status" json:"status"`
  128. }