diff --git a/src/main/java/com/mpnp/baechelin/api/controller/PublicApiController.java b/src/main/java/com/mpnp/baechelin/api/controller/PublicApiController.java index 6b34123..6291d0f 100644 --- a/src/main/java/com/mpnp/baechelin/api/controller/PublicApiController.java +++ b/src/main/java/com/mpnp/baechelin/api/controller/PublicApiController.java @@ -25,13 +25,10 @@ public class PublicApiController { @ApiOperation(value="공공 API V1을 통해 DB에 정보를 저장/업데이트하는 함수") @PostMapping("/api") public SuccessResponse getPublicApi(@Valid @RequestBody PublicApiRequestDto publicApiRequestDto) { - long start = currentTimeMillis(); publicApiService.processApiV1(publicApiRequestDto); -// ResponseEntity result = ResponseEntity.ok(publicApiService.processApiToDBWithWebclientMono(publicApiRequestDto)); - log.info("Elapsed Time : {}", currentTimeMillis() - start); return new SuccessResponse("공공 API V1 적용 완료"); } - //TODO 정리하기 + @ApiOperation(value="공공 API V2을 통해 DB에 정보를 저장/업데이트하는 함수") @GetMapping("/new-api") public SuccessResponse getPublicApiV2(@RequestParam String siDoNm, @@ -40,8 +37,8 @@ public SuccessResponse getPublicApiV2(@RequestParam String siDoNm, return new SuccessResponse("공공 API V2 적용 완료"); } - @GetMapping("test") - public void go() throws IOException, InterruptedException { + @GetMapping("/api-read") + public void go(@RequestParam String serviceKey){ publicApiServiceV2.start(); } } diff --git a/src/main/java/com/mpnp/baechelin/api/model/PublicApiV2Form.java b/src/main/java/com/mpnp/baechelin/api/model/PublicApiV2Form.java index 1ff8bb1..24ddcfb 100644 --- a/src/main/java/com/mpnp/baechelin/api/model/PublicApiV2Form.java +++ b/src/main/java/com/mpnp/baechelin/api/model/PublicApiV2Form.java @@ -44,15 +44,4 @@ public boolean validateServList() { } } - public List ApiFormToStore(PublicApiV2Form publicApiV2Form) { - List mappingResult = new ArrayList<>(); - for (ServList serv : publicApiV2Form.getServList()) { - mappingResult.add(Store.builder() - .address(serv.getLcMnad()) - .latitude(new BigDecimal(serv.faclLat)) - .longitude(new BigDecimal(serv.faclLng)) - .build()); - } - return mappingResult; - } } diff --git a/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java b/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java index 02de995..adb37cf 100644 --- a/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java +++ b/src/main/java/com/mpnp/baechelin/api/service/PublicApiServiceV2.java @@ -211,18 +211,28 @@ private List getStrings(PublicApiCategoryForm.ServList serv) { return null; } - public void start() throws IOException, InterruptedException { + public void start() { List list = new ArrayList<>(); BufferedReader br = null; - File file = ResourceUtils.getFile("classpath:static/sigungu.csv"); - br = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); + File file = null; + try { + file = ResourceUtils.getFile("classpath:static/sigungu.csv"); + br = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); + } catch (FileNotFoundException e) { + return; + } String line = null; - while ((line = br.readLine()) != null) { + while (true) { + try { + if (!((line = br.readLine()) != null)) break; + } catch (IOException e) { + return; + } String[] lineContents = line.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1); list.add(lineContents); } for (String[] strings : list) { - System.out.println("String 프린트중 : " + Arrays.toString(strings)); + log.info("{}, {} 처리중...", strings[0], strings[1]); processApi(strings[0], strings[1], 1); } }