2
0

fix: 修复更换omada参数问题

This commit is contained in:
caiyuchao
2025-01-15 17:59:23 +08:00
parent 6eaf2bf471
commit e173c62c0c
4 changed files with 42 additions and 3 deletions

View File

@@ -74,6 +74,15 @@ public class FeignConfig implements RequestInterceptor {
authorization = PRE_ACCESS_TOKEN + cacheAccessToken;
}
if (StrUtil.isNotBlank(authorization)) {
// 更新最新的omadaUrl和omadacId
requestTemplate.target(omadaProperties.getOmadaUrl());
String path = requestTemplate.path();
String uri = path.substring(path.indexOf("/openapi/v1/") + 12);
String lastUri = uri.substring(uri.indexOf("/"));
if (!uri.startsWith("msp")) {
requestTemplate.uri("/openapi/v1/" + omadaProperties.getOmadacId() + lastUri);
}
// 添加授权请求头
requestTemplate.header(AUTHORIZATION, authorization);
}
@@ -103,8 +112,7 @@ public class FeignConfig implements RequestInterceptor {
ResponseEntity<OmadaResult<AuthorizeTokenVO>> responseEntity = restTemplate.exchange(uriString, HttpMethod.POST,
request, new ParameterizedTypeReference<OmadaResult<AuthorizeTokenVO>>() {
});
OmadaResult<AuthorizeTokenVO> omadaResult = responseEntity.getBody();
return omadaResult;
return responseEntity.getBody();
}
}