Browse Source

연,월,일 별 통계조회을 위한 URL추가

pull/2/head
lkd9125 1 year ago
parent
commit
3ae1f4e7c6
  1. 13
      pav-server/src/main/java/com/palnet/biz/api/main/dash/controller/MainDashController.java
  2. 15
      pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java

13
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.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; 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 = "김포공항, 날짜 통계") @ApiOperation(value = "김포공항, 날짜 통계")
@Tag(name = "메인화면 컨트롤러", description = "메인화면 관련 API") @Tag(name = "메인화면 컨트롤러", description = "메인화면 관련 API")
@ApiImplicitParam(name = "yyyymm",value = "날짜", dataTypeClass = String.class) @ApiImplicitParam(name = "yyyymm",value = "날짜", dataTypeClass = String.class)
public ResponseEntity<? extends BasicResponse> kacDateStatistics(String yyyymm){ public ResponseEntity<? extends BasicResponse> kacDateStatistics(String yyyymm, @PathVariable String type){
String[] formatParam = null; String[] formatParam = null;
try { try {
if(yyyymm == null) yyyymm = ""; if(yyyymm == null) yyyymm = "";
formatParam = service.paramCheck(yyyymm); formatParam = service.paramCheck(yyyymm, type);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new ErrorResponse(RSErrorCode.ER_PARAM)); .body(new ErrorResponse(RSErrorCode.ER_PARAM));
@ -189,17 +190,17 @@ public class MainDashController {
return ResponseEntity.ok().body(new SuccessResponse<List<MainDashStcsModel>>(result)); return ResponseEntity.ok().body(new SuccessResponse<List<MainDashStcsModel>>(result));
} }
@GetMapping("/kac/stcs/plan-allow") @GetMapping("/kac/stcs/plan-allow/{type}")
@ApiOperation(value = "김포공항, 비행승인 통계") @ApiOperation(value = "김포공항, 비행승인 통계")
@Tag(name = "메인화면 컨트롤러", description = "메인화면 관련 API") @Tag(name = "메인화면 컨트롤러", description = "메인화면 관련 API")
@ApiImplicitParam(name = "yyyymm",value = "날짜", dataTypeClass = String.class) @ApiImplicitParam(name = "yyyymm",value = "날짜", dataTypeClass = String.class)
public ResponseEntity<? extends BasicResponse> kacPlanAllowStatistics(String yyyymm){ public ResponseEntity<? extends BasicResponse> kacPlanAllowStatistics(String yyyymm ,@PathVariable String type){
String[] formatParam = null; String[] formatParam = null;
try { try {
if(yyyymm == null) yyyymm = ""; if(yyyymm == null) yyyymm = "";
formatParam = service.paramCheck(yyyymm); formatParam = service.paramCheck(yyyymm,type);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new ErrorResponse(RSErrorCode.ER_PARAM)); .body(new ErrorResponse(RSErrorCode.ER_PARAM));

15
pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java

@ -131,7 +131,7 @@ public class MainDashService {
* @param yyyyMM * @param yyyyMM
* @throws NumberFormatException * @throws NumberFormatException
*/ */
public String[] paramCheck(String yyyymm) throws NumberFormatException{ public String[] paramCheck(String yyyymm, String type) throws NumberFormatException{
String[] result = new String[2]; String[] result = new String[2];
@ -141,14 +141,14 @@ public class MainDashService {
String[] paramStrings = yyyymm.split("-"); String[] paramStrings = yyyymm.split("-");
switch (yyyymm.length()) { switch (type) {
case 4: // 2. 월단위 검색 -> Parameter 2023등 연도만 있는경우 case "month": // 2. 월단위 검색 -> Parameter 2023등 연도만 있는경우
Integer.parseInt(yyyymm.trim()); Integer.parseInt(yyyymm.trim());
result[0] = "%Y"; result[0] = "%Y";
result[1] = "%m"; result[1] = "%m";
break; break;
case 7: // 3. 일단위 검색 -> Parameter 2023-09 등 월까지 있는경우 case "day": // 3. 일단위 검색 -> Parameter 2023-09 등 월까지 있는경우
if(paramStrings.length == 2){ if(paramStrings.length == 2){
for(String param : paramStrings){ for(String param : paramStrings){
@ -162,7 +162,7 @@ public class MainDashService {
} }
break; break;
case 10: // 4. 일일단위 검색 -> Parameter 2023-09-01 등 한 날짜에 대한 검색 case "one-day": // 4. 일일단위 검색 -> Parameter 2023-09-01 등 한 날짜에 대한 검색
if(paramStrings.length == 3){ if(paramStrings.length == 3){
for(String param : paramStrings){ for(String param : paramStrings){
@ -176,12 +176,15 @@ public class MainDashService {
throw new NumberFormatException(); throw new NumberFormatException();
} }
break; break;
default: // 1. 연단위 검색 -> Parameter Null일 경우 case "year" : // 1. 연단위 검색 -> Parameter Null일 경우
if(paramStrings.length > 1) throw new NumberFormatException(); if(paramStrings.length > 1) throw new NumberFormatException();
result[0] = ""; result[0] = "";
result[1] = "%y"; result[1] = "%y";
break; break;
default:
throw new NumberFormatException();
} }
return result; return result;

Loading…
Cancel
Save