From 3ae1f4e7c60047303bf013108138b866559c9dbf Mon Sep 17 00:00:00 2001 From: lkd9125 Date: Tue, 19 Sep 2023 15:38:13 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=B0,=EC=9B=94,=EC=9D=BC=20=EB=B3=84=20?= =?UTF-8?q?=ED=86=B5=EA=B3=84=EC=A1=B0=ED=9A=8C=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20URL=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/dash/controller/MainDashController.java | 15 ++++++++------- .../api/main/dash/service/MainDashService.java | 15 +++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pav-server/src/main/java/com/palnet/biz/api/main/dash/controller/MainDashController.java b/pav-server/src/main/java/com/palnet/biz/api/main/dash/controller/MainDashController.java index 505f8330..beb8083d 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/main/dash/controller/MainDashController.java +++ b/pav-server/src/main/java/com/palnet/biz/api/main/dash/controller/MainDashController.java @@ -11,6 +11,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -159,17 +160,17 @@ public class MainDashController { } - @GetMapping(value = "/kac/stcs/date") + @GetMapping(value = "/kac/stcs/date/{type}") @ApiOperation(value = "김포공항, 날짜 통계") @Tag(name = "메인화면 컨트롤러", description = "메인화면 관련 API") @ApiImplicitParam(name = "yyyymm",value = "날짜", dataTypeClass = String.class) - public ResponseEntity kacDateStatistics(String yyyymm){ - + public ResponseEntity kacDateStatistics(String yyyymm, @PathVariable String type){ + String[] formatParam = null; try { if(yyyymm == null) yyyymm = ""; - formatParam = service.paramCheck(yyyymm); + formatParam = service.paramCheck(yyyymm, type); } catch (NumberFormatException e) { return ResponseEntity.status(HttpStatus.OK) .body(new ErrorResponse(RSErrorCode.ER_PARAM)); @@ -189,17 +190,17 @@ public class MainDashController { return ResponseEntity.ok().body(new SuccessResponse>(result)); } - @GetMapping("/kac/stcs/plan-allow") + @GetMapping("/kac/stcs/plan-allow/{type}") @ApiOperation(value = "김포공항, 비행승인 통계") @Tag(name = "메인화면 컨트롤러", description = "메인화면 관련 API") @ApiImplicitParam(name = "yyyymm",value = "날짜", dataTypeClass = String.class) - public ResponseEntity kacPlanAllowStatistics(String yyyymm){ + public ResponseEntity kacPlanAllowStatistics(String yyyymm ,@PathVariable String type){ String[] formatParam = null; try { if(yyyymm == null) yyyymm = ""; - formatParam = service.paramCheck(yyyymm); + formatParam = service.paramCheck(yyyymm,type); } catch (NumberFormatException e) { return ResponseEntity.status(HttpStatus.OK) .body(new ErrorResponse(RSErrorCode.ER_PARAM)); diff --git a/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java b/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java index 40b02c09..e5b4c190 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java @@ -131,7 +131,7 @@ public class MainDashService { * @param yyyyMM * @throws NumberFormatException */ - public String[] paramCheck(String yyyymm) throws NumberFormatException{ + public String[] paramCheck(String yyyymm, String type) throws NumberFormatException{ String[] result = new String[2]; @@ -141,14 +141,14 @@ public class MainDashService { String[] paramStrings = yyyymm.split("-"); - switch (yyyymm.length()) { - case 4: // 2. 월단위 검색 -> Parameter 2023등 연도만 있는경우 + switch (type) { + case "month": // 2. 월단위 검색 -> Parameter 2023등 연도만 있는경우 Integer.parseInt(yyyymm.trim()); result[0] = "%Y"; result[1] = "%m"; break; - case 7: // 3. 일단위 검색 -> Parameter 2023-09 등 월까지 있는경우 + case "day": // 3. 일단위 검색 -> Parameter 2023-09 등 월까지 있는경우 if(paramStrings.length == 2){ for(String param : paramStrings){ @@ -162,7 +162,7 @@ public class MainDashService { } break; - case 10: // 4. 일일단위 검색 -> Parameter 2023-09-01 등 한 날짜에 대한 검색 + case "one-day": // 4. 일일단위 검색 -> Parameter 2023-09-01 등 한 날짜에 대한 검색 if(paramStrings.length == 3){ for(String param : paramStrings){ @@ -176,12 +176,15 @@ public class MainDashService { throw new NumberFormatException(); } break; - default: // 1. 연단위 검색 -> Parameter Null일 경우 + case "year" : // 1. 연단위 검색 -> Parameter Null일 경우 if(paramStrings.length > 1) throw new NumberFormatException(); result[0] = ""; result[1] = "%y"; + break; + default: + throw new NumberFormatException(); } return result;