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.
85 lines
2.0 KiB
85 lines
2.0 KiB
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
|
|
|
|
class Blog(BaseModel):
|
|
blogtitle:Annotated[str,Field(
|
|
title="博客标题",
|
|
pattern=r'^.{4,20}$',
|
|
examples=[""],
|
|
description="允许6-20个字符"
|
|
)]
|
|
blogcontent:Annotated[str,Field(
|
|
title="博客内容",
|
|
min_length=1,
|
|
description="最少1个字符"
|
|
)]
|
|
typeid:Annotated[int,Field(
|
|
title="类型id",
|
|
default=None,
|
|
description="类型id允许为空"
|
|
)]
|
|
descr:Annotated[str,Field(
|
|
title="备注",
|
|
default=None,
|
|
description="备注允许为空"
|
|
)]
|
|
|
|
class ResponseMessage(BaseModel):
|
|
status:int
|
|
message:str
|
|
data: object
|
|
|
|
|
|
class TypeList(BaseModel):
|
|
blogid:Annotated[int,Field(
|
|
title="博客id",
|
|
default=None,
|
|
description="博客id可以为空"
|
|
)]
|
|
typename:Annotated[str,Field(
|
|
title="类型名称",
|
|
examples=['typename'],
|
|
pattern=r'^.{2,50}$',
|
|
description="允许2-50个字符"
|
|
)]
|
|
descr:Annotated[str,Field(
|
|
title="备注",
|
|
default=None,
|
|
description="博客类型允许为空"
|
|
)]
|
|
|