users.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. class UsersBase(BaseModel):
  4. # 姓名
  5. name: str
  6. # 用户名称
  7. username: str
  8. # 密码明文
  9. password: str
  10. class UsersCreate(UsersBase):
  11. class Config:
  12. schema_extra = {
  13. "example": {
  14. "name": "wangyixiao",
  15. "username": "xiaogeer",
  16. "password": "Hello123!"
  17. }
  18. }
  19. class LoginBase(BaseModel):
  20. username: str
  21. password: str
  22. class Config:
  23. schema_extra = {
  24. "example": {
  25. "username": "xiaogeer",
  26. "password": "Hello123!"
  27. }
  28. }
  29. class AddUsersToProject(BaseModel):
  30. project_id: int
  31. user_ids: List[int]
  32. class Config:
  33. schema_extra = {
  34. "example": {
  35. "project_id": 1,
  36. "user_ids": [3,4]
  37. }
  38. }
  39. class RemoveUsersToProject(BaseModel):
  40. project_id: int
  41. user_id: int
  42. class Config:
  43. schema_extra = {
  44. "example": {
  45. "project_id": 1,
  46. "user_id": 4
  47. }
  48. }
  49. class SetUserToAdmin(BaseModel):
  50. project_id: int
  51. user_id: int
  52. class Config:
  53. schema_extra = {
  54. "example": {
  55. "project_id": 1,
  56. "user_id": 3
  57. }
  58. }