fix(warehouse): allow platform resource scope

This commit is contained in:
2026-08-10 16:34:11 +08:00
parent 59a4eb8ed5
commit 074a95d82b
2 changed files with 16 additions and 2 deletions
@@ -55,7 +55,7 @@ public class LocationResourceService {
@Resource
private PickingPackageAllocator packageAllocator;
public List<LocationEntity> findAvailable(@Min(1) long tenantId, @Min(1) long warehouseId,
public List<LocationEntity> findAvailable(@Min(0) long tenantId, @Min(1) long warehouseId,
@Min(1) @Max(200) int limit) {
requireLimit(limit);
requireActiveWarehouse(tenantId, warehouseId);
@@ -561,7 +561,7 @@ public class LocationResourceService {
}
@Transactional(readOnly = true)
public List<ActiveResource> findActiveResources(@Min(1) long tenantId,
public List<ActiveResource> findActiveResources(@Min(0) long tenantId,
@NotBlank String sourceService,
@Min(1) long businessId) {
List<ActiveResource> result = new ArrayList<>();
@@ -35,6 +35,20 @@ import static org.mockito.Mockito.when;
class LocationResourceServiceTest {
@MockBean private LocationRepository repository;
@Resource private LocationResourceService service;
@Test
void supportsPlatformScopedWarehouseResourceQueries() {
WarehouseEntity platformWarehouse = warehouse();
platformWarehouse.setTenantId(0L);
when(repository.findWarehouse(0L, 88L)).thenReturn(platformWarehouse);
when(repository.findAvailable(0L, 88L, 10)).thenReturn(List.of());
when(repository.findReservationsByBusiness(0L, "firstleg-service", 901L)).thenReturn(List.of());
when(repository.findOccupanciesByBusiness(0L, "firstleg-service", 901L)).thenReturn(List.of());
assertThat(service.findAvailable(0L, 88L, 10)).isEmpty();
assertThat(service.findActiveResources(0L, "firstleg-service", 901L)).isEmpty();
}
@Test
void shouldHandleCase01() {
when(repository.findWarehouse(10001L, 88L)).thenReturn(warehouse());