perf(warehouse): 优化库存商品更新操作的性能

- 在保存库存商品实体后,添加了 EntityManager 的 flush 操作
- 这样可以确保在更新数据库之前,所有待处理的变更都被提交- 从而避免不必要的数据库查询,提高系统性能
This commit is contained in:
2025-03-17 23:08:43 +08:00
parent 72dc690d02
commit fb4eac458d

View File

@@ -60,6 +60,7 @@ public class WarehouseGoodsService
WarehouseGoodsEntity entity = mapper.toEntity(request); WarehouseGoodsEntity entity = mapper.toEntity(request);
this.repository.save(entity); this.repository.save(entity);
em.flush();
em.refresh(entity); em.refresh(entity);
return getById(entity.getId()); return getById(entity.getId());
} }