role.py 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from typing import Optional, List
  4. from pydantic import BaseModel
  5. from admin.schemas.sysdata.sysmodule import SysApiItem
  6. from schemas.base import ListMixin, DetailMixin
  7. class RoleItem(BaseModel):
  8. id: int
  9. name: str
  10. is_active: bool
  11. class Config:
  12. orm_mode = True
  13. class RoleItemList(ListMixin):
  14. data: Optional[List[RoleItem]] = []
  15. class CreateRole(BaseModel):
  16. name: str
  17. description: str = ""
  18. creator: int = 0
  19. class UpdateRole(BaseModel):
  20. name: Optional[str] = None
  21. description: Optional[str] = None
  22. editor: Optional[int] = None
  23. class RoleDetail(DetailMixin):
  24. data: Optional[RoleItem] = None
  25. class CreateRoleApi(BaseModel):
  26. role_id: int
  27. api_id: int
  28. class RoleApiList(ListMixin):
  29. data: Optional[List[SysApiItem]] = []
  30. class AssignRoleApi(BaseModel):
  31. role_id: Optional[int] = None
  32. apis: List[int]