【fix sonar】RestUtil文件
This commit is contained in:
+9
-6
@@ -1,6 +1,7 @@
|
|||||||
package com.jero.common.util;
|
package com.jero.common.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jero.common.exception.JeroBootException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
@@ -20,6 +21,10 @@ import java.util.Map;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class RestUtil {
|
public class RestUtil {
|
||||||
|
|
||||||
|
private RestUtil(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static String domain = null;
|
private static String domain = null;
|
||||||
|
|
||||||
public static String getDomain() {
|
public static String getDomain() {
|
||||||
@@ -188,10 +193,10 @@ public class RestUtil {
|
|||||||
public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {
|
public static <T> ResponseEntity<T> request(String url, HttpMethod method, HttpHeaders headers, JSONObject variables, Object params, Class<T> responseType) {
|
||||||
log.info(" RestUtil --- request --- url = "+ url);
|
log.info(" RestUtil --- request --- url = "+ url);
|
||||||
if (StringUtils.isEmpty(url)) {
|
if (StringUtils.isEmpty(url)) {
|
||||||
throw new RuntimeException("url 不能为空");
|
throw new JeroBootException("url 不能为空");
|
||||||
}
|
}
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
throw new RuntimeException("method 不能为空");
|
throw new JeroBootException("method 不能为空");
|
||||||
}
|
}
|
||||||
if (headers == null) {
|
if (headers == null) {
|
||||||
headers = new HttpHeaders();
|
headers = new HttpHeaders();
|
||||||
@@ -243,10 +248,8 @@ public class RestUtil {
|
|||||||
String key = it.next();
|
String key = it.next();
|
||||||
String value = "";
|
String value = "";
|
||||||
Object object = source.get(key);
|
Object object = source.get(key);
|
||||||
if (object != null) {
|
if (object != null && !StringUtils.isEmpty(object.toString())) {
|
||||||
if (!StringUtils.isEmpty(object.toString())) {
|
value = object.toString();
|
||||||
value = object.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
urlVariables.append("&").append(key).append("=").append(value);
|
urlVariables.append("&").append(key).append("=").append(value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user