Files
video/schema/face_schema.py

31 lines
1.2 KiB
Python
Raw Permalink Normal View History

2025-09-03 20:07:38 +08:00
from datetime import datetime
from pydantic import BaseModel, Field
# ------------------------------
# 请求模型(前端传参校验)
# ------------------------------
class FaceCreateRequest(BaseModel):
2025-09-08 17:34:23 +08:00
"""创建人脸记录请求模型无需ID、由数据库自增"""
name: str = Field(None, max_length=255, description="名称可选、最长255字符")
2025-09-03 20:07:38 +08:00
class FaceUpdateRequest(BaseModel):
2025-09-03 21:41:26 +08:00
"""更新人脸记录请求模型(不变)"""
2025-09-03 20:07:38 +08:00
name: str = Field(None, max_length=255, description="名称")
2025-09-03 21:41:26 +08:00
eigenvalue: str = Field(None, max_length=255, description="特征(文件处理后可更新)")
2025-09-03 20:07:38 +08:00
# ------------------------------
# 响应模型(后端返回数据)
# ------------------------------
class FaceResponse(BaseModel):
2025-09-08 17:34:23 +08:00
"""人脸记录响应模型仍包含ID、由数据库生成后返回"""
2025-09-03 21:41:26 +08:00
id: int = Field(..., description="主键ID数据库自增")
2025-09-03 20:07:38 +08:00
name: str = Field(None, description="名称")
2025-09-04 22:59:27 +08:00
eigenvalue: str | None = Field(None, description="特征(可为空)")
2025-09-03 20:07:38 +08:00
created_at: datetime = Field(..., description="记录创建时间")
updated_at: datetime = Field(..., description="记录更新时间")
2025-09-04 22:59:27 +08:00
model_config = {"from_attributes": True}