mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-02-20 20:10:14 +00:00
单容器重构
This commit is contained in:
@@ -11,6 +11,7 @@ from models import ExamStatus, QuestionType
|
||||
class UserCreate(BaseModel):
|
||||
username: str = Field(..., min_length=3, max_length=50)
|
||||
password: str = Field(..., min_length=6)
|
||||
is_admin: bool = False # 支持管理员创建用户时指定角色
|
||||
|
||||
@validator('username')
|
||||
def username_alphanumeric(cls, v):
|
||||
@@ -19,6 +20,19 @@ class UserCreate(BaseModel):
|
||||
return v
|
||||
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
"""用户更新 Schema(所有字段可选)"""
|
||||
username: Optional[str] = Field(None, min_length=3, max_length=50)
|
||||
password: Optional[str] = Field(None, min_length=6)
|
||||
is_admin: Optional[bool] = None
|
||||
|
||||
@validator('username')
|
||||
def username_alphanumeric(cls, v):
|
||||
if v is not None and not v.replace('_', '').replace('-', '').isalnum():
|
||||
raise ValueError('Username must be alphanumeric (allows _ and -)')
|
||||
return v
|
||||
|
||||
|
||||
class UserLogin(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
@@ -39,6 +53,14 @@ class UserResponse(BaseModel):
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class UserListResponse(BaseModel):
|
||||
"""用户列表响应(包含分页信息)"""
|
||||
users: List[dict] # 包含额外统计信息的用户列表
|
||||
total: int
|
||||
skip: int
|
||||
limit: int
|
||||
|
||||
|
||||
# ============ System Config Schemas ============
|
||||
class SystemConfigUpdate(BaseModel):
|
||||
allow_registration: Optional[bool] = None
|
||||
|
||||
Reference in New Issue
Block a user