You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
879 B
34 lines
879 B
from pydantic import BaseModel,Field
|
|
from typing import Annotated
|
|
|
|
# Token相关的模型
|
|
class Token(BaseModel):
|
|
access_token: str
|
|
token_type: str
|
|
|
|
class TokenData(BaseModel):
|
|
username: str = None
|
|
|
|
# User相关的模型
|
|
class User(BaseModel):
|
|
username: Annotated[str,Field(
|
|
title="用户",
|
|
examples=["admin"],
|
|
pattern=r'^.{4,20}$',
|
|
description="允许4-20的字符"
|
|
)]
|
|
email: Annotated[str,Field(
|
|
examples=["examples@example.com"],
|
|
max_length=50,
|
|
pattern=r'^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$',
|
|
description="邮箱需要满足正则标准"
|
|
)]
|
|
full_name: Annotated[str,Field(
|
|
examples=["admin"],
|
|
pattern=r'^.{2,20}$',
|
|
description="允许2-20个字符"
|
|
)]
|
|
disabled: bool = True
|
|
|
|
class UserInDB(User):
|
|
hashed_password: str = None
|