Files

43 lines
1.4 KiB
Python
Raw Permalink 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.
"""采集上传(插件 → 服务端)请求/响应模型,对齐 docs/extension/plan.md §14。"""
from __future__ import annotations
from pydantic import BaseModel, Field
class SourceInfo(BaseModel):
platform: str = Field(..., description="ozon | 1688 | taobao")
itemId: str | None = None
url: str = ""
collectedAt: int | None = None # epoch 毫秒
class TextMaterial(BaseModel):
kind: str = Field(..., description="title | params | selling_point | desc | price | brand")
content: str = ""
pairs: list[dict] | None = None # table 模式 kv[{key, value}]
class ImageMaterial(BaseModel):
groupKey: str = Field(..., description="main | sku | detail | video | param")
groupName: str = ""
variantName: str | None = None # SKU 规格名
url: str = Field(..., description="源站原图 URL")
index: int = 0
type: str = "img" # img | video
dedupeKey: str | None = None
class MaterialsRequest(BaseModel):
product_id: str | None = Field(default=None, description="传了=追加到已有商品(跨平台补素材)")
source: SourceInfo
texts: list[TextMaterial] = Field(default_factory=list)
images: list[ImageMaterial] = Field(default_factory=list)
refererOrigin: str | None = None # 下载源图时需带的 Referer
class MaterialsResponse(BaseModel):
product_id: str
stage: str
assets_queued: int
assets_skipped: int = 0 # 因 dedupeKey 重复而跳过