初始化

This commit is contained in:
ZZX9599
2025-09-02 18:51:50 +08:00
commit fe1b33a6e5
30 changed files with 1607 additions and 0 deletions

32
schema/user_schema.py Normal file
View File

@ -0,0 +1,32 @@
from datetime import datetime
from pydantic import BaseModel, Field
# ------------------------------
# 请求模型(前端传参校验)
# ------------------------------
class UserRegisterRequest(BaseModel):
"""用户注册请求模型"""
username: str = Field(..., min_length=3, max_length=50, description="用户名3-50字符")
password: str = Field(..., min_length=6, max_length=100, description="密码6-100字符")
class UserLoginRequest(BaseModel):
"""用户登录请求模型"""
username: str = Field(..., description="用户名")
password: str = Field(..., description="密码")
# ------------------------------
# 响应模型(后端返回用户数据)
# ------------------------------
class UserResponse(BaseModel):
"""用户信息响应模型(隐藏密码等敏感字段)"""
id: int = Field(..., description="用户ID")
username: str = Field(..., description="用户名")
created_at: datetime = Field(..., description="创建时间")
updated_at: datetime = Field(..., description="更新时间")
# Pydantic V2 配置(支持从数据库查询结果转换)
model_config = {"from_attributes": True}