fix: 基础信息修改其它字段时不再误清空 product_image(图片消失)——仅显式携带 generalImage 才更新图片

This commit is contained in:
yueli
2026-09-03 14:12:15 +08:00
parent 4f8d765bb3
commit 7fe861b4a7

View File

@ -671,6 +671,8 @@ class MaterialBaseService:
if 'generalManual' in data:
material.manual_link = json.dumps(data['generalManual'])
# ★ 仅当 payload 明确携带 generalImage 时才更新图片(含传 [] 表示清空);
# 修改其他字段时不动图片,避免误清空 product_image
if 'generalImage' in data:
new_photo_list = data['generalImage']
material.product_image = json.dumps(new_photo_list)
@ -685,11 +687,11 @@ class MaterialBaseService:
material.id,
new_photo_list
)
else:
material.product_image = None
ImageEmbeddingService.delete_embeddings(
ImageEmbeddingService.MODULE_MATERIAL_BASE, material.id
)
else:
# 图片被清空([])时,同步清理该物料的图片向量
ImageEmbeddingService.delete_embeddings(
ImageEmbeddingService.MODULE_MATERIAL_BASE, material.id
)
# 【核心修改】:兼容前端传来的布尔值
if 'referencePrice' in data: