feat: 升级1.1.0,解决get传参

This commit is contained in:
wangyu 2023-02-20 12:25:53 +08:00
parent b60caa6bd2
commit a8f7c6adf4
4 changed files with 25 additions and 5 deletions

View File

@ -13,7 +13,7 @@
<groupId>group.flyfish</groupId>
<artifactId>rest-proxy</artifactId>
<version>1.0.9</version>
<version>1.1.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
@ -22,7 +22,7 @@
<java.version>1.8</java.version>
<commons-collection.version>4.4</commons-collection.version>
<commons.lang.version>2.6</commons.lang.version>
<sdk.version>1.0.9</sdk.version>
<sdk.version>1.1.0</sdk.version>
</properties>
<packaging>pom</packaging>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>group.flyfish</groupId>
<artifactId>rest-proxy</artifactId>
<version>1.0.9</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>group.flyfish</groupId>
<artifactId>rest-proxy</artifactId>
<version>1.0.9</version>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -21,10 +21,30 @@ public abstract class AbstractParamResolver {
if (DataUtils.isNotEmpty(builder.getParams())) {
String start = builder.getUrl().contains("?") ? "&" : "?";
String params = builder.getParams().entrySet().stream()
.map(entry -> entry.getKey() + "=" + (null == entry.getValue() ? "" : entry.getValue()))
.map(entry -> entry.getKey() + "=" + parseValue(entry.getValue()))
.collect(Collectors.joining("&"));
builder.url(builder.getUrl() + start + params);
}
return builder;
}
/**
* 解析值
*
* @param value
* @return 结果
*/
private String parseValue(Object value) {
if (value instanceof String) {
return (String) value;
}
if (value instanceof Iterable) {
Iterable<? extends CharSequence> mapped = DataUtils.cast(value);
return String.join(",", mapped);
}
if (null != value) {
return String.valueOf(value);
}
return "";
}
}