|
|
@@ -15,6 +15,7 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
import com.style24.persistence.domain.KCertifyNo;
|
|
|
+import com.style24.persistence.domain.KCertifyNoOnly;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
@@ -60,11 +61,24 @@ public class SafetyKoreaApi {
|
|
|
*/
|
|
|
public GagaMap getKoreaCertifyNo(String goodsCd) throws Exception {
|
|
|
|
|
|
+ GagaMap result = new GagaMap();
|
|
|
+
|
|
|
String requestUrl = apiUrl + "?conditionKey=all&conditionValue=" + goodsCd;
|
|
|
log.info("requestUrl: {}", requestUrl);
|
|
|
URI url = URI.create(requestUrl);
|
|
|
|
|
|
- return getExtracted( url);
|
|
|
+ String responseJson = getExtracted( url);
|
|
|
+
|
|
|
+ Gson gson = new Gson();
|
|
|
+ KCertifyNo kcNo = gson.fromJson(responseJson, KCertifyNo.class);
|
|
|
+
|
|
|
+ if (kcNo.getResultCode() != null && "2000".equals(kcNo.getResultCode())) { // 성공
|
|
|
+ result.set("certNum", kcNo.getResultData().iterator().next().getCertNum());
|
|
|
+ result.set("certDt", kcNo.getResultData().iterator().next().getCertDate() );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -78,11 +92,23 @@ public class SafetyKoreaApi {
|
|
|
*/
|
|
|
public GagaMap getKoreaCertifyDetail(String certNum) throws Exception {
|
|
|
|
|
|
+ GagaMap result = new GagaMap();
|
|
|
+
|
|
|
String requestUrl = apiDetailUrl + "?certNum=" + certNum;
|
|
|
- log.info("requestUrl: {}", requestUrl);
|
|
|
URI url = URI.create(requestUrl);
|
|
|
|
|
|
- return getExtracted( url);
|
|
|
+ String responseJson = getExtracted( url);
|
|
|
+
|
|
|
+ Gson gson = new Gson();
|
|
|
+ KCertifyNoOnly kcNo = gson.fromJson(responseJson, KCertifyNoOnly.class);
|
|
|
+
|
|
|
+ if (kcNo.getResultCode() != null && "2000".equals(kcNo.getResultCode())) { // 성공
|
|
|
+ result.set("certNum", kcNo.getResultData().getCertNum());
|
|
|
+ result.set("certDt", kcNo.getResultData().getCertDate() );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -94,10 +120,9 @@ public class SafetyKoreaApi {
|
|
|
* @author eskim
|
|
|
* @since 2020. 12. 07
|
|
|
*/
|
|
|
- private GagaMap getExtracted( URI url) {
|
|
|
-
|
|
|
- GagaMap result = new GagaMap();
|
|
|
+ private String getExtracted( URI url) {
|
|
|
|
|
|
+ String responseJson = "";
|
|
|
// Header
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
|
|
@@ -108,7 +133,7 @@ public class SafetyKoreaApi {
|
|
|
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, String.class);
|
|
|
log.info("responseEntity.getStatusCode(): {} ", responseEntity.getStatusCode());
|
|
|
|
|
|
- String responseJson = responseEntity.getBody();
|
|
|
+ responseJson = responseEntity.getBody();
|
|
|
log.info("responseEntity.getBody(): {}", responseJson);
|
|
|
|
|
|
// {
|
|
|
@@ -143,16 +168,7 @@ public class SafetyKoreaApi {
|
|
|
// ]
|
|
|
// }
|
|
|
|
|
|
- Gson gson = new Gson();
|
|
|
- KCertifyNo kcNo = gson.fromJson(responseJson, KCertifyNo.class);
|
|
|
-
|
|
|
- if (kcNo.getResultCode() != null && kcNo.getResultCode().equals("2000")) { // 성공
|
|
|
- result.set("certNum", kcNo.getResultData().iterator().next().getCertNum());
|
|
|
- result.set("certDt", kcNo.getResultData().iterator().next().getCertDate() );
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
+ return responseJson;
|
|
|
}
|
|
|
|
|
|
}
|