This commit is contained in:
2026-09-29 17:55:54 +08:00
parent 41d8387cd5
commit 54ad26c607
111 changed files with 1837 additions and 962 deletions
@@ -9,30 +9,23 @@ import com.baiyue.warehouse.security.OverseasWarehousePermissions;
import com.baiyue.warehouse.dto.PalletRequests;
import com.baiyue.warehouse.entity.WarehousePalletEntity;
import com.baiyue.warehouse.service.WarehouseResourceService;
import com.baiyue.warehouse.service.DomesticWarehouseDirectory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import jakarta.validation.Valid;
import java.util.List;
/** Exposes the domestic authoritative directory as read-only overseas resource options. */
/** Cross-warehouse queries for overseas resources; warehouse masters belong to Warehouse. */
@RestController
@RequestMapping("/api/platform/v1/warehouse-admin")
@RequestMapping("/api/platform/v1/overseas-warehouse-resources")
@Tag(name = "Platform overseas warehouse directory")
public class PlatformWarehouseDirectoryController {
private final DomesticWarehouseDirectory directory;
private final WarehouseResourceService resources;
public PlatformWarehouseDirectoryController(DomesticWarehouseDirectory directory,
WarehouseResourceService resources) {
this.directory = directory;
public PlatformWarehouseDirectoryController(WarehouseResourceService resources) {
this.resources = resources;
}
@@ -56,29 +49,6 @@ public class PlatformWarehouseDirectoryController {
return ApiResponse.success(resources.publicPalletSummary(WarehouseResourceService.PUBLIC_RESOURCE_SCOPE, query));
}
@GetMapping
@PreAuthorize("hasAuthority('" + OverseasWarehousePermissions.WAREHOUSE_LIST + "')")
@Operation(summary = "Page shared overseas receiving warehouses",
description = "Required authority: " + OverseasWarehousePermissions.WAREHOUSE_LIST)
public ApiResponse<PageResult<WarehouseOption>> warehouses(
@AuthenticationPrincipal AuthenticatedUser user,
@RequestParam(defaultValue = "1") long page,
@RequestParam(defaultValue = "200") long size) {
requirePlatform(user);
if (page < 1 || size < 1 || size > 200) {
throw new BizException(ResultCode.BAD_REQUEST, "分页参数无效");
}
List<WarehouseOption> all = directory.options().stream()
.map(value -> new WarehouseOption(value.warehouseId(), 0L, value.warehouseCode(),
value.warehouseName(), "OVERSEAS", value.status()))
.toList();
long from = Math.min((page - 1) * size, all.size());
long to = Math.min(from + size, all.size());
long pages = all.isEmpty() ? 0 : (all.size() + size - 1) / size;
return ApiResponse.success(new PageResult<>(all.subList((int) from, (int) to),
page, size, all.size(), pages));
}
private static void requirePlatform(AuthenticatedUser user) {
if (user == null || !"PLATFORM".equals(user.appCode())
|| user.tenantId() == null || user.tenantId() != 0L) {
@@ -86,6 +56,4 @@ public class PlatformWarehouseDirectoryController {
}
}
public record WarehouseOption(long id, long customerId, String warehouseCode,
String warehouseName, String warehouseType, String status) { }
}
@@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
@Validated
@RestController
@RequestMapping("/api/platform/v1/warehouse-admin/{warehouseId}")
@RequestMapping("/api/platform/v1/overseas-warehouse-resources/{warehouseId}")
@Tag(name = "Platform overseas warehouse resources")
public class PlatformWarehouseResourceController {
@Resource private WarehouseResourceService service;
@@ -1,26 +0,0 @@
package com.baiyue.warehouse.controller;
import com.baiyue.common.core.api.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 仓库微服务可用性接口,向平台端暴露服务逻辑状态。
*/
@Tag(name = "Warehouse service status / 仓储服务状态", description = "Warehouse service availability API. / 仓储服务可用性接口。")
@RestController
@RequestMapping("/api/platform/v1/warehouses")
public class WarehouseHealthController {
@Operation(summary = "Get service status / 查询服务状态", description = "Returns the logical status of warehouse-overseas-service. / 返回 warehouse-overseas-service 的逻辑运行状态。")
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "Service is available / 服务可用")
@GetMapping("/status")
public ApiResponse<Map<String, String>> status() {
return ApiResponse.success(Map.of("service", "warehouse-overseas-service", "status", "UP"));
}
}