fix: 基础信息修改其它字段时不再误清空 product_image(图片消失)——仅显式携带 generalImage 才更新图片
This commit is contained in:
@ -671,6 +671,8 @@ class MaterialBaseService:
|
|||||||
|
|
||||||
if 'generalManual' in data:
|
if 'generalManual' in data:
|
||||||
material.manual_link = json.dumps(data['generalManual'])
|
material.manual_link = json.dumps(data['generalManual'])
|
||||||
|
# ★ 仅当 payload 明确携带 generalImage 时才更新图片(含传 [] 表示清空);
|
||||||
|
# 修改其他字段时不动图片,避免误清空 product_image
|
||||||
if 'generalImage' in data:
|
if 'generalImage' in data:
|
||||||
new_photo_list = data['generalImage']
|
new_photo_list = data['generalImage']
|
||||||
material.product_image = json.dumps(new_photo_list)
|
material.product_image = json.dumps(new_photo_list)
|
||||||
@ -686,7 +688,7 @@ class MaterialBaseService:
|
|||||||
new_photo_list
|
new_photo_list
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
material.product_image = None
|
# 图片被清空([])时,同步清理该物料的图片向量
|
||||||
ImageEmbeddingService.delete_embeddings(
|
ImageEmbeddingService.delete_embeddings(
|
||||||
ImageEmbeddingService.MODULE_MATERIAL_BASE, material.id
|
ImageEmbeddingService.MODULE_MATERIAL_BASE, material.id
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user