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 Label(BaseModel): id:Annotated[int,Field( title="标签id", description="主键自增" )] labelname:Annotated[str,Field( title="标签名称", description="名称不允许为空" )] descr:Annotated[str,Field( title="备注", default=None, description="备注允许为空" )] 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个字符" )] imglink:Annotated[str,Field( title="文图地址", )] typeid:Annotated[int,Field( title="类型id", default=None, description="类型id允许为空" )] descr:Annotated[str,Field( title="备注", default=None, description="备注允许为空" )] class Classtic(BaseModel): header:Annotated[str,Field( title="语录名称", description="语录名称不允许为空" )] text:Annotated[str,Field( title="语录内容", description="语录内容不允许为空" )] descr:Annotated[str,Field( title="备注", default=None, description="备注允许为空" )] class ComLink(BaseModel): linktext:Annotated[str,Field( title="链接名称", description="名称不允许为空" )] linkurl:Annotated[str,Field( title="链接地址", description="地址不允许为空" )] descr:Annotated[str,Field( title="备注", default=None, description="备注允许为空" )] class Type(BaseModel): typename:Annotated[str,Field( title="类型名称", description="名称不允许为空" )] descr:Annotated[str,Field( title="备注", default=None, description="备注允许为空" )]