Files
AIPortPilot/backend/app/schemas/report.py
T
selfrelease 263f474c90 feat(backend): T1.3 月报管理 CRUD — 列表/详情/创建/更新/提交/删除
- 路由:GET/POST/PUT/DELETE /api/v1/reports + POST /reports/{id}/submit
- 状态机:draft → submitted → ai_parsed → reviewed
- 防重复:同年同月同企业不可重复创建
- 租户隔离:通过 company 关联校验
- 测试:7 个月报测试(总计 33 tests passed)
2026-07-18 22:00:34 +08:00

53 lines
1.3 KiB
Python

"""月报相关 Pydantic schema。"""
from datetime import datetime
from pydantic import BaseModel, Field
class MonthlyReportCreate(BaseModel):
"""创建月报请求。"""
company_id: str
period_year: int = Field(..., ge=2020, le=2100)
period_month: int = Field(..., ge=1, le=12)
raw_content: str | None = None
class MonthlyReportUpdate(BaseModel):
"""更新月报请求。"""
raw_content: str | None = None
status: str | None = Field(default=None, description="draft/submitted/ai_parsed/reviewed")
structured_data: dict | None = None
ai_summary: str | None = None
ai_concerns: dict | None = None
class MonthlyReportResponse(BaseModel):
"""月报信息响应。"""
id: str
company_id: str
period_year: int
period_month: int
status: str
raw_content: str | None = None
structured_data: dict | None = None
ai_summary: str | None = None
ai_concerns: dict | None = None
submitted_by: str | None = None
submitted_at: datetime | None = None
reviewed_by: str | None = None
reviewed_at: datetime | None = None
created_at: datetime
updated_at: datetime
class MonthlyReportListResponse(BaseModel):
"""月报列表响应。"""
items: list[MonthlyReportResponse]
total: int
page: int
page_size: int