model.py 798 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """
  2. encoding: UTF-8
  3. @author:clx
  4. @file:model.py
  5. @time:2023/5/30 6:29
  6. """
  7. from typing import Optional, Union
  8. from pydantic import BaseModel
  9. class Item(BaseModel):
  10. id: int
  11. name: str
  12. class Token(BaseModel):
  13. access_token: str
  14. token_type: str
  15. class TokenData(BaseModel):
  16. username: Union[str, None] = None
  17. class User(BaseModel):
  18. username: str
  19. email: Union[str, None] = None
  20. full_name: Union[str, None] = None
  21. disabled: Union[bool, None] = None
  22. class UserInDB(User):
  23. hashed_password: str
  24. fake_users_db = {
  25. "clx": {
  26. "username": "clx",
  27. "full_name": "Lixu Cao",
  28. "email": "clx@example.com",
  29. "hashed_password": "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW",
  30. "disabled": False,
  31. }
  32. }