Procházet zdrojové kódy

KC 인증 관련 - 인증번호로 조회 추가

eskim před 5 roky
rodič
revize
d7395835b5

+ 42 - 5
style24.core/src/main/java/com/style24/core/biz/thirdparty/SafetyKoreaApi.java

@@ -33,6 +33,8 @@ public class SafetyKoreaApi {
 	// URL
 	private String apiUrl = "http://www.safetykorea.kr/openapi/api/cert/certificationList.json";
 
+	private String apiDetailUrl = "http://www.safetykorea.kr/openapi/api/cert/certificationDetail.json";
+
 	// 인증키
 	private String authKey = "34fa9888-a2fb-4c02-adf4-18f018bb936d";
 
@@ -43,12 +45,13 @@ public class SafetyKoreaApi {
 	public void init() {
 		log.debug("\n\n---- SafetyKoreaApi initialization started ----");
 		log.debug("apiUrl: [{}]", apiUrl);
+		log.debug("apiDetailUrl: [{}]", apiDetailUrl);
 		log.debug("authKey: [{}]", authKey);
 		log.debug("\n--- SafetyKoreaApi initialization completed ----\n");
 	}
 
 	/**
-	 * KC인증번호 조회
+	 * KC인증번호 정보 조회
 	 * @param goodsCd - 상품코드
 	 * @return 인증번호
 	 * @throws Exception
@@ -56,16 +59,50 @@ public class SafetyKoreaApi {
 	 * @since 2020. 12. 1
 	 */
 	public GagaMap getKoreaCertifyNo(String goodsCd) throws Exception {
+
+		String requestUrl = apiUrl + "?conditionKey=all&conditionValue=" + goodsCd;
+		log.info("requestUrl: {}", requestUrl);
+		URI url = URI.create(requestUrl);
+
+		return getExtracted( url);
+	}
+
+
+	/**
+	 * KC인증번호로 조회
+	 * @param certNum - 인증번호
+	 * @return
+	 * @throws Exception
+	 * @author eskim
+	 * @since 2020. 12. 07
+	 */
+	public GagaMap getKoreaCertifyDetail(String certNum) throws Exception {
+
+		String requestUrl = apiDetailUrl + "?certNum=" + certNum;
+		log.info("requestUrl: {}", requestUrl);
+		URI url = URI.create(requestUrl);
+
+		return getExtracted( url);
+
+	}
+
+	/**
+	 * KC인증정보 조회
+	 * @param url - KC인증 URL
+	 * @return
+	 * @throws Exception
+	 * @author eskim
+	 * @since 2020. 12. 07
+	 */
+	private GagaMap getExtracted( URI url) {
+
 		GagaMap result = new GagaMap();
+
 		// Header
 		HttpHeaders headers = new HttpHeaders();
 		headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
 		headers.add("AuthKey", authKey);
 
-		String requestUrl = apiUrl + "?conditionKey=all&conditionValue=" + goodsCd;
-		log.info("requestUrl: {}", requestUrl);
-		URI url = URI.create(requestUrl);
-
 		// GET방식으로 호출
 		HttpEntity<String> request = new HttpEntity<String>(headers);
 		ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, String.class);