Files
max_code_test_gitea_2/scheme/users.py
T
2026-09-11 23:40:12 +08:00

27 lines
806 B
Python

# scheme/users.py
from pydantic import BaseModel, Field, EmailStr
from datetime import datetime
from typing import Optional
# ---------- 请求模型 ----------
class UserCreate(BaseModel):
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr
full_name: Optional[str] = Field(None, max_length=100)
class UserUpdate(BaseModel):
username: Optional[str] = Field(None, min_length=3, max_length=50)
email: Optional[EmailStr] = None
full_name: Optional[str] = Field(None, max_length=100)
# ---------- 响应模型 ----------
class UserResponse(BaseModel):
id: int
username: str
email: str
full_name: Optional[str]
created_at: datetime
updated_at: Optional[datetime]
class Config:
from_attributes = True # 支持 ORM 对象转换