fix(phase4): enforce customer and pallet versions
This commit is contained in:
+7
-1
@@ -152,6 +152,9 @@ public class WarehouseResourceService {
|
||||
@Transactional
|
||||
public void updatePallet(long customerId, long warehouseId, long id, PalletRequests.SaveRequest request) {
|
||||
WarehousePalletEntity existing = requirePallet(customerId, warehouseId, id);
|
||||
if (request.version() == null || !request.version().equals(existing.getVersion())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘版本已变化,请刷新后重试");
|
||||
}
|
||||
if ("SCRAPPED".equals(existing.getStatus()) && !"SCRAPPED".equals(request.status())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "SCRAPPED pallet cannot be reused");
|
||||
}
|
||||
@@ -161,7 +164,10 @@ public class WarehouseResourceService {
|
||||
validatePallet(request, palletCode, locationId, customerId, warehouseId, id);
|
||||
WarehousePalletEntity entity = palletEntity(customerId, warehouseId, request, palletCode, locationId);
|
||||
entity.setId(existing.getId());
|
||||
repository.updatePallet(entity);
|
||||
entity.setVersion(request.version());
|
||||
if (repository.updatePallet(entity) != 1) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘版本已变化,请刷新后重试");
|
||||
}
|
||||
}
|
||||
|
||||
public WarehousePalletEntity pallet(long customerId, long warehouseId, long id) {
|
||||
|
||||
Reference in New Issue
Block a user