This commit is contained in:
2026-08-07 14:46:55 +08:00
parent 830575cc92
commit b0ea1a0c5c
109 changed files with 5774 additions and 339 deletions
@@ -15,6 +15,8 @@ import java.security.MessageDigest;
@RestController
@RequestMapping("/internal/warehouses")
public class InternalWarehouseController {
private static final long PLATFORM_TENANT_ID = 0L;
@Resource
private WarehouseApplicationService service;
@@ -30,8 +32,17 @@ public class InternalWarehouseController {
public ApiResponse<WarehouseDetailResponse> active(
@RequestHeader(value="X-Internal-Service-Token", required=false) String token,
@PathVariable long tenantId, @PathVariable long id) {
if (token == null || !MessageDigest.isEqual(expected, token.getBytes(StandardCharsets.UTF_8)))
verifyToken(token);
if (tenantId != PLATFORM_TENANT_ID) {
throw new BizException(ResultCode.BAD_REQUEST, "平台公共仓库作用域必须为0");
}
return ApiResponse.success(service.activeDetail(PLATFORM_TENANT_ID, id));
}
private void verifyToken(String token) {
byte[] supplied = token == null ? new byte[0] : token.getBytes(StandardCharsets.UTF_8);
if (!MessageDigest.isEqual(expected, supplied)) {
throw new BizException(ResultCode.FORBIDDEN, "内部服务凭证无效");
return ApiResponse.success(service.activeDetail(tenantId, id));
}
}
}