From d5819e8f3a8b355192f31d85b56a8990590acc05 Mon Sep 17 00:00:00 2001 From: sunga Date: Sun, 17 Sep 2023 17:04:21 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=82=AB=ED=88=AC=EB=91=90=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=EC=8B=9C=20=EB=82=A0=EC=A7=9C=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EC=B2=B4=ED=81=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nottodo/controller/NotToDoController.java | 14 ++++++++++++++ .../bside/NotToDoClub/global/error/ErrorCode.java | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/bside/NotToDoClub/domain_name/nottodo/controller/NotToDoController.java b/src/main/java/bside/NotToDoClub/domain_name/nottodo/controller/NotToDoController.java index 1210460..9518298 100644 --- a/src/main/java/bside/NotToDoClub/domain_name/nottodo/controller/NotToDoController.java +++ b/src/main/java/bside/NotToDoClub/domain_name/nottodo/controller/NotToDoController.java @@ -2,6 +2,8 @@ import bside.NotToDoClub.domain_name.nottodo.dto.*; import bside.NotToDoClub.domain_name.nottodo.service.NotToDoService; +import bside.NotToDoClub.global.error.CustomException; +import bside.NotToDoClub.global.error.ErrorCode; import bside.NotToDoClub.global.response.ResponseCode; import bside.NotToDoClub.global.response.ResultResponse; import io.swagger.v3.oas.annotations.Operation; @@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.text.SimpleDateFormat; import java.util.List; @RestController @@ -44,6 +47,17 @@ public ResultResponse> getNotToDoList(@Request public ResultResponse createNotToDo( @RequestHeader(value="access-token")String accessToken, @RequestBody @Valid NotToDoCreateRequestDto notToDoCreateRequestDto){ + + try{ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + sdf.setLenient(false); + sdf.parse(notToDoCreateRequestDto.getStartDate()); + sdf.parse(notToDoCreateRequestDto.getEndDate()); + } catch (Exception e){ + throw new CustomException(ErrorCode.DATETIME_FORMAT_PARSING_ERROR); + } + + NotToDoCreateResponseDto notToDo = notToDoService.createNotToDo(accessToken, notToDoCreateRequestDto); return ResultResponse.of(ResponseCode.CREATE_USER_NOT_TO_DO, notToDo); } diff --git a/src/main/java/bside/NotToDoClub/global/error/ErrorCode.java b/src/main/java/bside/NotToDoClub/global/error/ErrorCode.java index a77439d..ce9af4d 100644 --- a/src/main/java/bside/NotToDoClub/global/error/ErrorCode.java +++ b/src/main/java/bside/NotToDoClub/global/error/ErrorCode.java @@ -34,7 +34,7 @@ public enum ErrorCode { /* 500 INTERNAL SERVER ERROR : 서버 내부 오류 */ ALREADY_TOS_AGREE(INTERNAL_SERVER_ERROR,"이미 이용약관에 동의한 회원입니다."), REGISTER_NOT_TO_DO_LIMIT(INTERNAL_SERVER_ERROR, "등록한 낫투두 갯수가 7개를 초과했습니다."), - DATETIME_FORMAT_PARSING_ERROR(INTERNAL_SERVER_ERROR, "날짜 형식 파싱오류"), + DATETIME_FORMAT_PARSING_ERROR(INTERNAL_SERVER_ERROR, "날짜 형식 파싱오류 (날짜 형식은 yyyy-mm-dd)"), BADGE_PRESENT_FAIL(INTERNAL_SERVER_ERROR, "사용자 뱃지 등록 중 오류가 발생했습니다."); private final HttpStatus status;