role.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from typing import List, Optional
  4. from pydantic import Field
  5. from pydantic.main import BaseModel
  6. from schemas.base import ListMixin, Datetime2Str, DetailMixin
  7. class RoleInfo(BaseModel):
  8. id: Optional[int] = None
  9. name: str = Field(..., description="角色名称")
  10. platform: str = Field(..., description="备注")
  11. remark: Optional[str] = Field(None, description="备注")
  12. permission_codes: Optional[str] = None
  13. creator_name: str = Field(None, description="创建人名称")
  14. created_at: Optional[Datetime2Str] = Field(None, description="创建时间")
  15. class Config:
  16. orm_mode = True
  17. anystr_strip_whitespace = True
  18. class RoleList(ListMixin):
  19. data: List[RoleInfo] = []
  20. class RoleDetail(DetailMixin):
  21. data: Optional[RoleInfo] = {}
  22. class PermissionItem(BaseModel):
  23. id: int = Field(..., description="id")
  24. name: str = Field(..., description="名称")
  25. codename: str = Field(..., description="权限代码")
  26. remark: Optional[str] = Field(None, description="备注")
  27. platform: str = Field(..., description="平台")
  28. api: str = Field(None, description="接口地址")
  29. method: str = Field(None, description="请求方法")
  30. order: int = Field(..., description="排序字段")
  31. class Config:
  32. orm_mode = True
  33. anystr_strip_whitespace = True
  34. class PermissionList(ListMixin):
  35. data: List[PermissionItem] = []