-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] refactor: request DTO Validation 추가(#462) #463
Conversation
# Conflicts: # backend/src/main/java/com/festago/auth/dto/LoginRequest.java # backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java
충돌나는거 수정했고, 예외 메시지 일괄적이게 변경했습니다! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~
추가적으로 적용해야할 부분에 대해 커멘트 밑에 남기겠습니다!
@NotNull(message = "name 은 null 일 수 없습니다.") String name, | ||
@DateTimeFormat(iso = ISO.DATE) LocalDate startDate, | ||
@DateTimeFormat(iso = ISO.DATE) LocalDate endDate, | ||
@NotBlank(message = "name은 공백일 수 없습니다.") String name, | ||
@NotNull(message = "startDate는 null 일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE) LocalDate startDate, | ||
@NotNull(message = "endDate는 null 일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE) LocalDate endDate, | ||
String thumbnail, | ||
@NotNull(message = "schoolId는 null 일 수 없습니다.") Long schoolId | ||
) { | ||
@NotNull(message = "schoolId는 null 일 수 없습니다.") Long schoolId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
검증 어노테이션이 많아 가독성이 낮아져 컨벤션을 정해야 할 것 같네요!
제 생각에는 해당 방식이 좋아보이는데 어떠신가요?
public record FestivalCreateRequest(
@NotBlank(message = "name 은 공백일 수 없습니다.")
String name,
@NotNull(message = "startDate 는 null 일 수 없습니다.")
@DateTimeFormat(iso = ISO.DATE)
LocalDate startDate,
@NotNull(message = "endDate 는 null 일 수 없습니다.")
@DateTimeFormat(iso = ISO.DATE)
LocalDate endDate,
String thumbnail) {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동의보감입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
진행시켜!
일부 Contorller에 public class StudentController {
...
@PostMapping("/send-verification")
public ResponseEntity<Void> sendEmail(@Member Long memberId,
@RequestBody StudentSendMailRequest request) {
studentService.sendVerificationMail(memberId, request);
return ResponseEntity.ok()
.build();
}
...
} |
지금 @RestControllerAdvice
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
...
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException e, HttpHeaders headers,
HttpStatusCode status, WebRequest request) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ErrorResponse.from(ErrorCode.INVALID_REQUEST_ARGUMENT));
}
...
} |
|
죄송합니다 에임 이슈로 잠시 닫았었네요 😅 |
# Conflicts: # backend/src/main/java/com/festago/presentation/AuthController.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꿋이에요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!
* feat: StudentSendMailRequest validation 추가 * feat: StudentVerificateRequest validation 추가 * refactor: FestivalCreateRequest NotNull/NotBlank 제약조건 추가 * refactor: TicketValidationRequest NotNull -> NotBlank 로 변경 * refactor: LoginRequest NotNull -> NotBlank 로 변경 * feat: Request DTO Validation 추가 * refactor: 예외 메시지 일괄적이게 변경 * style: 개행 일괄 적용 * refactor: Controller의 Request Body @Valid 적용 * refactor: 상수 오타 수정 * refactor: Validation Error 메세지 자세하게 수정 --------- Co-authored-by: seokjin8678 <[email protected]>
* feat: StudentSendMailRequest validation 추가 * feat: StudentVerificateRequest validation 추가 * refactor: FestivalCreateRequest NotNull/NotBlank 제약조건 추가 * refactor: TicketValidationRequest NotNull -> NotBlank 로 변경 * refactor: LoginRequest NotNull -> NotBlank 로 변경 * feat: Request DTO Validation 추가 * refactor: 예외 메시지 일괄적이게 변경 * style: 개행 일괄 적용 * refactor: Controller의 Request Body @Valid 적용 * refactor: 상수 오타 수정 * refactor: Validation Error 메세지 자세하게 수정 --------- Co-authored-by: seokjin8678 <[email protected]>
📌 관련 이슈
✨ PR 세부 내용