refactor(warehouse): 刷新实体以获取最新数据

- 在创建和更新仓库商品后,添加实体刷新操作
- 确保返回的数据是最新的,避免潜在的并发问题
This commit is contained in:
2025-03-17 21:27:57 +08:00
parent e9f609413b
commit 0ef826800e

View File

@@ -54,10 +54,13 @@ public class WarehouseGoodsService
@Autowired private ConversionService conversionService;
public WarehouseGoodsDto create(CreateWarehouseGoodsDto request) {
WarehouseGoodsEntity entity = mapper.toEntity(request);
this.repository.save(entity);
em.refresh(entity);
return getById(entity.getId());
}
@@ -67,6 +70,8 @@ public class WarehouseGoodsService
this.repository.save(entity);
em.refresh(entity);
return getById(entity.getId());
}