This commit is contained in:
2026-07-30 10:30:50 +08:00
parent cf6d708566
commit 853c478657
85 changed files with 4711 additions and 1052 deletions
+5 -5
View File
@@ -114,7 +114,7 @@ async def create_product(
product_dict["max_stock"] = 0
product = Product(**product_dict)
db_session.add(product)
await db_session.commit()
await db_session.flush()
await db_session.refresh(product)
return _build_product_response(product, 0)
@@ -178,7 +178,7 @@ async def create_product_from_task(
db_session.add(product)
await db_session.flush()
stp_file.product_id = product.id
await db_session.commit()
await db_session.flush()
await db_session.refresh(product)
return _build_product_response(product, 0)
@@ -205,7 +205,7 @@ async def update_product(
for key, value in product_dict.items():
setattr(product, key, value)
await db_session.commit()
await db_session.flush()
await db_session.refresh(product)
material_cost_map = await _calculate_material_cost_map(db_session, [product.id])
return _build_product_response(product, material_cost_map.get(product.id, 0))
@@ -223,7 +223,7 @@ async def delete_product(
raise HTTPException(status_code=404, detail="产品不存在")
product.is_active = False
await db_session.commit()
await db_session.flush()
return {"message": "产品已删除"}
@@ -321,5 +321,5 @@ async def replace_product_bom(
)
)
await db_session.commit()
await db_session.flush()
return await get_product_bom(product_id, db_session, current_user)