28 lines
908 B
Python
28 lines
908 B
Python
"""
|
|
导入相关 Schema — 请求 / 响应模型
|
|
"""
|
|
|
|
from datetime import date
|
|
from typing import Optional
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class ImportError(BaseModel):
|
|
"""单行失败详情"""
|
|
row_number: int # Excel 行号(第2行=第1条数据)
|
|
reason: str # 失败原因
|
|
raw_data: dict # 原始行数据(字典形式)
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ImportResult(BaseModel):
|
|
"""批量导入响应"""
|
|
batch_id: str # UUID,用于下载失败行 Excel
|
|
total_rows: int # 总行数
|
|
success_count: int # 成功数
|
|
failed_count: int # 失败数
|
|
errors: list[ImportError] # 失败行列表
|
|
error_excel_url: Optional[str] = None # 失败行 Excel 下载 URL(无可失败行时可不返回)
|
|
|
|
model_config = ConfigDict(from_attributes=True) |