fix: 商品库生成的三视图打 view=three_view 标记,刷新不丢 (ZWQ#5 续)

真因:商品库点「AI生成三视图」走 reference_product 路径,产出资产 name=「图片创作」、
metadata 只有 mode/product_id —— 没有 view=three_view,也非 tri_view 类。导致:
①商品库详情三视图面板刷新后认不出(显示「尚未生成」、采用也丢);
②视频项目第二步基础资产读不到「商品已有三视图」。

修:reference_product 资产与视频项目基础资产阶段生成的商品三视图同款标记 ——
category=product_image + 名字含「商品三视图」+ metadata.view=three_view + product_id。
这样 products is_triview(排除 product_image 不误入角色区)、商品库前端回填(view===three_view)、
视频项目商品三视图判定都能认出。需部署生效;存量旧资产无标记不追溯。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-06-30 11:40:23 +08:00
co-authored by Claude Opus 4.8
parent c827191a36
commit 77759678a7
+9 -2
View File
@@ -2419,9 +2419,16 @@ def run_standalone_image_task(*, task_id: str) -> None:
asset_id = uuid.uuid4()
object_key = f"teams/{team.id}/standalone/{asset_id}{suffix}"
stored = TosStorage().upload_fileobj(fileobj=fileobj, object_key=object_key, content_type=content_type)
asset_label = {"model": "模特上身图", "cover": "平台套图", "image": "图片创作"}.get(mode, mode)
# 商品三视图(reference_product):与视频项目基础资产阶段生成的商品三视图同款标记 ——
# category=product_image + 名字含「商品三视图」+ metadata.view=three_view + product_id。
# 否则商品库自己生成的三视图认不出(无 view 标记),刷新即丢、视频项目第二步也读不到「商品已有三视图」(ZWQ#5 续)。
is_product_triview = bool(payload.get("reference_product"))
asset_label = "商品三视图" if is_product_triview else {"model": "模特上身图", "cover": "平台套图", "image": "图片创作"}.get(mode, mode)
asset_category = Asset.Category.PRODUCT_IMAGE if is_product_triview else category
# 资产元数据:product_id(商品详情页据此只展示该商品素材)+ batch_id(成组)+ mode + model_entity_id(上身图溯源模特库)
asset_meta: dict = {"mode": mode}
if is_product_triview:
asset_meta["view"] = "three_view"
if product_id:
asset_meta["product_id"] = str(product_id)
if payload.get("batch_id"):
@@ -2430,7 +2437,7 @@ def run_standalone_image_task(*, task_id: str) -> None:
asset_meta["model_entity_id"] = str(payload["model_entity_id"])
asset = Asset.objects.create(
id=asset_id, team=team, created_by=user, name=f"AI 生成 · {asset_label} · {index + 1}",
asset_type=Asset.Type.IMAGE, source=Asset.Source.AI_GENERATED, category=category, origin_task=task,
asset_type=Asset.Type.IMAGE, source=Asset.Source.AI_GENERATED, category=asset_category, origin_task=task,
metadata=asset_meta,
# 工作台生成的图默认不进资产库列表,只在工作台展示;用户「加入资产库」后才置 True
in_library=False,