user_and_role.go 987 B

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