From efe2ec6416d1de8196ce0f61154503a29a60e5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Mon, 24 Nov 2025 17:19:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8F=91=E7=A5=A8=E6=A8=A1=E5=9E=8B):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0app=5Fuser=5Fid=E5=AD=97=E6=AE=B5=E5=B9=B6?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E5=B1=9E=E6=80=A7=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(估值模型): 修改historical_evidence类型并添加URL验证器 在发票模型中添加可选用户ID字段并配置ORM属性转换 在估值模型中调整历史证据字段类型为字典并添加URL字段验证逻辑 --- app/schemas/invoice.py | 3 +++ app/schemas/valuation.py | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/schemas/invoice.py b/app/schemas/invoice.py index 20154bb..2699bfd 100644 --- a/app/schemas/invoice.py +++ b/app/schemas/invoice.py @@ -14,6 +14,7 @@ class InvoiceHeaderCreate(BaseModel): class InvoiceHeaderOut(BaseModel): id: int + app_user_id: Optional[int] = None company_name: str tax_number: str register_address: str @@ -21,6 +22,8 @@ class InvoiceHeaderOut(BaseModel): bank_name: str bank_account: str email: EmailStr + class Config: + from_attributes = True class InvoiceHeaderUpdate(BaseModel): diff --git a/app/schemas/valuation.py b/app/schemas/valuation.py index 9e58d1d..5165f69 100644 --- a/app/schemas/valuation.py +++ b/app/schemas/valuation.py @@ -104,7 +104,7 @@ class ValuationAssessmentUpdate(BaseModel): inheritor_certificates: Optional[List[Any]] = Field(None, description="非遗传承人等级证书") heritage_level: Optional[str] = Field(None, description="非遗等级") patent_application_no: Optional[str] = Field(None, description="非遗资产所用专利的申请号") - historical_evidence: Optional[List[Any]] = Field(None, description="非遗资产历史证明证据及数量") + historical_evidence: Optional[Dict[str, int]] = Field(None, description="非遗资产历史证明证据及数量") patent_certificates: Optional[List[Any]] = Field(None, description="非遗资产所用专利的证书") pattern_images: Optional[List[Any]] = Field(None, description="非遗纹样图片") report_url: Optional[str] = Field(None, description="评估报告URL") @@ -129,6 +129,20 @@ class ValuationAssessmentUpdate(BaseModel): is_active: Optional[bool] = Field(None, description="是否激活") + @field_validator('report_url', 'certificate_url', mode='before') + @classmethod + def _coerce_url(cls, v): + if v is None: + return None + if isinstance(v, list) and v: + v = v[0] + if isinstance(v, str): + s = v.strip() + if s.startswith('`') and s.endswith('`'): + s = s[1:-1].strip() + return s + return v + class ValuationAssessmentOut(ValuationAssessmentBase): """估值评估输出模型"""