Skip to content

Commit

Permalink
#18 [Refactor] 쓰지 않는 함수 정리, 예외처리 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 30, 2022
1 parent eaefce4 commit 0e10a20
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PublicApiResponseDto> 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,
Expand All @@ -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();
}
}
11 changes: 0 additions & 11 deletions src/main/java/com/mpnp/baechelin/api/model/PublicApiV2Form.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,4 @@ public boolean validateServList() {
}
}

public List<Store> ApiFormToStore(PublicApiV2Form publicApiV2Form) {
List<Store> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,28 @@ private List<String> getStrings(PublicApiCategoryForm.ServList serv) {
return null;
}

public void start() throws IOException, InterruptedException {
public void start() {
List<String[]> 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);
}
}
Expand Down

0 comments on commit 0e10a20

Please sign in to comment.