|
|
|
@ -16,11 +16,8 @@ import java.net.*; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.http.HttpResponse; |
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
@ -31,8 +28,6 @@ import org.springframework.web.reactive.function.client.WebClient.RequestBodySpe |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.net.ssl.HttpsURLConnection; |
|
|
|
|
|
|
|
import static cn.hutool.poi.excel.sax.AttributeName.t; |
|
|
|
|
|
|
|
@Component |
|
|
|
public class IvsCommonService { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(IvsCommonService.class); |
|
|
|
@ -50,7 +45,7 @@ public class IvsCommonService { |
|
|
|
|
|
|
|
public String getCookie() { |
|
|
|
String cookie = redisService.getCacheObject(IvsConst.IVS_TOKEN); |
|
|
|
//log.debug("[GAB] cookie: {}", cookie); |
|
|
|
log.info(Color.YELLOW + "[IVS] cookie: {}" + Color.END, cookie); |
|
|
|
return cookie; |
|
|
|
} |
|
|
|
|
|
|
|
@ -70,13 +65,28 @@ public class IvsCommonService { |
|
|
|
public <T> T get(String uri, Class<T> clazz) { |
|
|
|
String cookie = this.getCookie(); |
|
|
|
String res = HttpUtil.createGet(getAddress().concat(uri)) |
|
|
|
.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
|
//.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
|
.cookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME.concat("=").concat(cookie)) |
|
|
|
.execute() |
|
|
|
.body(); |
|
|
|
//log.info("[IVS] GET URI: {}, RES: {}", uri, res); |
|
|
|
log.info("[IVS] GET URI: {}, RES: {}", uri, res); |
|
|
|
return checkResultCodeAndConvertResult(JSONObject.parseObject(res), clazz); |
|
|
|
} |
|
|
|
|
|
|
|
public <T> T getJson(String uri, Class<T> clazz) { |
|
|
|
String cookie = this.getCookie(); |
|
|
|
String res = HttpUtil.createGet(getAddress().concat(uri)) |
|
|
|
.cookie(new HttpCookie[]{new HttpCookie(IvsConst.HTTP_JSESSIONID_SESSION_NAME, cookie)}) |
|
|
|
.execute() |
|
|
|
.body(); |
|
|
|
|
|
|
|
JSONObject t = http(HttpMethod.GET, uri) |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.cookie("JSESSIONID", cookie).retrieve().bodyToMono(JSONObject.class).block(); |
|
|
|
log.info("[CALL IVS] getJson POST, Response:{}", t.toJSONString()); |
|
|
|
return this.checkResultCodeAndConvertResult(t, clazz); |
|
|
|
} |
|
|
|
|
|
|
|
public JSONObject getResultJson(String uri) { |
|
|
|
String cookie = this.getCookie(); |
|
|
|
JSONObject result = this.http(HttpMethod.GET, uri) |
|
|
|
|