Skip to content

Commit

Permalink
feat: 낫투두 등록시 날짜형식 유효성 체크 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
sunga08 committed Sep 17, 2023
1 parent 053a175 commit d5819e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -10,6 +12,7 @@
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.List;

@RestController
Expand Down Expand Up @@ -44,6 +47,17 @@ public ResultResponse<List<NotToDoListCUMsgResponseDto>> getNotToDoList(@Request
public ResultResponse<NotToDoCreateResponseDto> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d5819e8

Please sign in to comment.