|
@@ -50,6 +50,13 @@ public class RequestDecoderFilter extends AbstractGatewayFilterFactory<Object> {
|
|
|
|
|
|
|
|
private static final String PARAM_NAME = "value";
|
|
private static final String PARAM_NAME = "value";
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 前端所传分页名称
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final String PAGE_NAME = "pageNum";
|
|
|
|
|
+ private static final String SIZE_NAME = "pageSize";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public GatewayFilter apply(Object config) {
|
|
public GatewayFilter apply(Object config) {
|
|
|
return (exchange, chain) -> {
|
|
return (exchange, chain) -> {
|
|
@@ -154,7 +161,16 @@ public class RequestDecoderFilter extends AbstractGatewayFilterFactory<Object> {
|
|
|
JSONObject decryptJson = JSON.parseObject(decryptStr);
|
|
JSONObject decryptJson = JSON.parseObject(decryptStr);
|
|
|
//构建新的请求参数webflux
|
|
//构建新的请求参数webflux
|
|
|
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(decryptJson.size());
|
|
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(decryptJson.size());
|
|
|
- decryptJson.forEach((key, value) -> parameters.add(key, URLEncoder.encode(String.valueOf(value), StandardCharsets.UTF_8)));
|
|
|
|
|
|
|
+ decryptJson.forEach((key, value) -> {
|
|
|
|
|
+ //转换分页参数,前后端定义不一致的问题
|
|
|
|
|
+ if(PAGE_NAME.equals(key)){
|
|
|
|
|
+ key = "current";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(SIZE_NAME.equals(key)){
|
|
|
|
|
+ key = "size";
|
|
|
|
|
+ }
|
|
|
|
|
+ parameters.add(key, URLEncoder.encode(String.valueOf(value), StandardCharsets.UTF_8));
|
|
|
|
|
+ });
|
|
|
// 构建修改后的URI
|
|
// 构建修改后的URI
|
|
|
URI modifiedUri = UriComponentsBuilder.fromUri(exchange.getRequest().getURI())
|
|
URI modifiedUri = UriComponentsBuilder.fromUri(exchange.getRequest().getURI())
|
|
|
.replaceQueryParams(parameters)
|
|
.replaceQueryParams(parameters)
|