Преглед изворни кода

KC인증정보 조회 수정

gagamel пре 5 година
родитељ
комит
7dc32b4ce3

+ 43 - 3
style24.core/src/main/java/com/style24/core/biz/thirdparty/SafetyKoreaApi.java

@@ -76,10 +76,50 @@ public class SafetyKoreaApi {
 		String responseJson = responseEntity.getBody();
 		log.info("responseEntity.getBody(): {}", responseJson);
 
-		JSONParser jsonParser = new JSONParser();
-		JSONObject jObj = (JSONObject)jsonParser.parse(responseJson);
+//		{
+//		    "resultCode": "2000",
+//		    "resultMsg": "Success",
+//		    "resultData": [
+//		        {
+//		            "certUid": 4675807,
+//		            "certOrganName": "FITI시험연구원(FITI)",
+//		            "certNum": "CB015R0919-8001",
+//		            "certState": "적합",
+//		            "certDiv": "어린이제품 특별법 대상>안전확인 대상",
+//		            "certDate": "20180703",
+//		            "certChgDate": null,
+//		            "certChgReason": "",
+//		            "firstCertNum": null,
+//		            "productName": "유아용 섬유제품",
+//		            "brandName": "",
+//		            "modelName": "MNW1BQKP20",
+//		            "categoryName": "어린이>유아용 섬유제품",
+//		            "importDiv": "수입",
+//		            "makerName": "INWOO",
+//		            "makerCntryName": "인도네시아",
+//		            "importerName": "(주)아은",
+//		            "remark": "",
+//		            "signDate": "20200629",
+//		            "derivationModels": null,
+//		            "certificationImageUrls": null,
+//		            "factories": null,
+//		            "similarCertifications": null
+//		        }
+//		    ]
+//		}
 
-		return jObj.get("certNum").toString();
+		JSONParser jsonParser = new JSONParser();
+		JSONObject jsonObj = (JSONObject)jsonParser.parse(responseJson);
+		String resultCode = jsonObj.get("resultCode").toString();
+		String certNum = "";
+		if (resultCode != null && resultCode.equals("2000")) { // 성공
+			JSONObject resultData = (JSONObject)jsonParser.parse(jsonObj.get("resultData").toString());
+			if (resultData != null) {
+				certNum = resultData.get("certNum").toString();
+			}
+		}
+
+		return certNum;
 	}
 
 }