fix(gateway): 补充预检请求标识过滤器

This commit is contained in:
2026-07-31 18:24:48 +08:00
parent 9a37657148
commit b1d4ef39e2
5 changed files with 150 additions and 1 deletions
@@ -110,7 +110,9 @@ public class OrderMasterDataGuard {
return new BizException(ResultCode.SERVICE_UNAVAILABLE,
"主数据内部服务凭证不一致,请检查 INTERNAL_SERVICE_TOKEN");
}
log.warn("订单主数据内部调用失败,已转换为 S0503", exception);
log.warn("订单主数据内部调用失败,已转换为 S0503,异常类型={},原因={}",
exception.getClass().getSimpleName(), exception.getMessage());
log.debug("订单主数据内部调用完整堆栈", exception);
return unavailable("主数据");
}
private FeignException findFeignException(Throwable exception) {
@@ -0,0 +1,29 @@
package com.baiyue.order.client;
import org.junit.jupiter.api.Test;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import java.lang.reflect.Method;
import static org.assertj.core.api.Assertions.assertThat;
class WarehouseFeignContractTest {
@Test void clientsUseNacosServiceNameAndInternalPathsByDefault() throws Exception {
assertClient(WarehouseClient.class, "/internal/warehouses");
assertClient(PartnerClient.class, "/internal/warehouse-partners");
}
private void assertClient(Class<?> type, String expectedPath) throws Exception {
FeignClient client = type.getAnnotation(FeignClient.class);
assertThat(client.name()).isEqualTo("warehouse-service");
assertThat(client.url()).isEqualTo("${baiyue.clients.warehouse.url:}");
assertThat(client.path()).isEqualTo(expectedPath);
Method active = type.getMethod("active", String.class, long.class, long.class);
assertThat(active.getAnnotation(GetMapping.class).value()).containsExactly("/{tenantId}/{id}/active");
RequestHeader header = active.getParameters()[0].getAnnotation(RequestHeader.class);
assertThat(header.value()).isEqualTo("X-Internal-Service-Token");
}
}