diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsCommonService.java b/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsCommonService.java index ae777cc..3dcde04 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsCommonService.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsCommonService.java @@ -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 get(String uri, Class 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 getJson(String uri, Class 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) diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsLoginService.java b/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsLoginService.java index b60ed1d..792c466 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsLoginService.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/service/IvsLoginService.java @@ -1,5 +1,6 @@ package com.inspect.ivs.service; +import com.inspect.base.core.constant.Color; import com.inspect.base.core.exception.ServiceException; import com.inspect.ivs.base.feign.domain.IvsResult; import com.inspect.ivs.config.IvsUserConfig; @@ -93,7 +94,7 @@ public class IvsLoginService extends IvsCommonService { } private IvsResult login() { - logger.info("-------------------------ivs user: " + this.queryUser()); + logger.info("-------------------------ivs user: {}", this.queryUser()); return this.http(HttpMethod.POST, IvsConst.URI_LOGIN) .contentType(MediaType.APPLICATION_JSON) .bodyValue(this.queryUser()) @@ -101,7 +102,7 @@ public class IvsLoginService extends IvsCommonService { List header = res.headers().header(IvsConst.COOKIE_KEY); System.out.println(header.size()); String token = (res.headers().header(IvsConst.COOKIE_KEY).get(0)).split("=")[1].split(";")[0]; - logger.debug("===================token:{}", token); + logger.info(Color.YELLOW + "===================ivs token:{}" + Color.END, token); this.setCookie(token); return res.bodyToMono(IvsResult.class); }).block();