Files
video/schema/sensitive_schema.py
2025-09-03 22:58:16 +08:00

31 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime
from pydantic import BaseModel, Field
# ------------------------------
# 请求模型(前端传参校验)
# ------------------------------
class SensitiveCreateRequest(BaseModel):
"""创建敏感信息记录请求模型"""
# 移除了id字段由数据库自动生成
name: str = Field(None, max_length=255, description="名称")
class SensitiveUpdateRequest(BaseModel):
"""更新敏感信息记录请求模型"""
name: str = Field(None, max_length=255, description="名称")
# ------------------------------
# 响应模型(后端返回数据)
# ------------------------------
class SensitiveResponse(BaseModel):
"""敏感信息记录响应模型"""
id: int = Field(..., description="主键ID") # 响应中仍然包含ID
name: str = Field(None, description="名称")
created_at: datetime = Field(..., description="记录创建时间")
updated_at: datetime = Field(..., description="记录更新时间")
# 支持从数据库查询结果转换
model_config = {"from_attributes": True}