初次代码

This commit is contained in:
jianqi
2026-09-11 23:40:12 +08:00
commit cea442451d
11 changed files with 338 additions and 0 deletions
View File
+27
View File
@@ -0,0 +1,27 @@
# 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 对象转换