user.py 978 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import datetime
  2. from typing import Optional, List
  3. from pydantic import BaseModel
  4. # Shared properties
  5. class UserBase(BaseModel):
  6. username: str
  7. nickname: str
  8. sex: str
  9. identity_card: str
  10. phone: Optional[str] = None
  11. # address: Optional[str] = None
  12. work_start: Optional[str] = datetime.datetime.today()
  13. status: Optional[str] = None
  14. hashed_password: str = get_password_hash(settings.INIT_PASSWORD)
  15. # avatar: Optional[str] = None
  16. introduction: Optional[str] = None
  17. is_active: Optional[bool] = True
  18. # Properties to receive via API on creation
  19. class UserCreate(UserBase):
  20. deptId: Optional[int] = None
  21. postIds: List[int] = []
  22. roleIds: List[int] = []
  23. # Properties to receive via API on update
  24. class UserUpdate(UserBase):
  25. id: Optional[int] = None
  26. deptId: Optional[int] = None
  27. postIds: List[int] = []
  28. roleIds: List[int] = []
  29. # reset password
  30. class UserPWReset(BaseModel):
  31. user_id: int
  32. password: str