role_and_permission.go 1.0 KB

1234567891011121314151617181920212223242526272829
  1. package relations
  2. import (
  3. "git.sxidc.com/go-framework/baize/convenient/domain/auth/permission"
  4. "git.sxidc.com/go-framework/baize/convenient/domain/auth/role"
  5. "git.sxidc.com/go-framework/baize/convenient/relation/many2many"
  6. "git.sxidc.com/go-framework/baize/framework/binding"
  7. )
  8. // SimpleRoleAndPermission Bind参数
  9. type SimpleRoleAndPermission struct {
  10. // schema
  11. Schema string
  12. // 鉴权中间件
  13. AuthMiddleware binding.Middleware
  14. }
  15. func (simple *SimpleRoleAndPermission) Bind(binder *binding.Binder) {
  16. many2many.BindSimple(binder, &many2many.Simple[role.Info, permission.Info]{
  17. Left: &role.Entity{},
  18. Right: &permission.Entity{},
  19. Schema: simple.Schema,
  20. LeftUpdateJsonBody: &role.UpdatePermissionsOfRoleJsonBody{},
  21. LeftQueryQueryParams: &role.GetPermissionsOfRoleQueryParams{},
  22. RightUpdateJsonBody: &permission.UpdateRolesOfPermissionJsonBody{},
  23. RightQueryQueryParams: &permission.GetRolesOfPermissionQueryParams{},
  24. }, many2many.WithGlobalMiddlewares(simple.AuthMiddleware))
  25. }