From df074d547958c5aff2a6076bd53511e9f95c43a7 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Tue, 26 Sep 2023 16:52:00 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat:=20StudentSendMailRequest=20validati?= =?UTF-8?q?on=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/student/dto/StudentSendMailRequest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java b/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java index f58238144..fd7c76ae8 100644 --- a/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java +++ b/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java @@ -1,8 +1,11 @@ package com.festago.student.dto; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + public record StudentSendMailRequest( - String username, - Long schoolId + @NotBlank(message = "username은 공백일 수 없습니다.") String username, + @NotNull(message = "schoolId는 null 일 수 없습니다.") Long schoolId ) { } From f36419b14745a66c7aca55c91f66d13bf951e745 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Tue, 26 Sep 2023 16:52:08 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat:=20StudentVerificateRequest=20valida?= =?UTF-8?q?tion=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/student/dto/StudentVerificateRequest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java b/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java index 8e9053d1d..4cf000f92 100644 --- a/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java +++ b/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java @@ -1,5 +1,9 @@ package com.festago.student.dto; -public record StudentVerificateRequest(String code) { +import jakarta.validation.constraints.NotBlank; + +public record StudentVerificateRequest( + @NotBlank(message = "code는 공백일 수 없습니다.") String code +) { } From c271b9168e3b22d0539ab731dc8c7e9385a4d379 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Tue, 26 Sep 2023 16:52:57 +0900 Subject: [PATCH 03/11] =?UTF-8?q?refactor:=20FestivalCreateRequest=20NotNu?= =?UTF-8?q?ll/NotBlank=20=EC=A0=9C=EC=95=BD=EC=A1=B0=EA=B1=B4=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 --- .../festago/festival/dto/FestivalCreateRequest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java b/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java index fd908a0f1..4399ca625 100644 --- a/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java +++ b/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java @@ -1,15 +1,20 @@ package com.festago.festival.dto; import com.festago.festival.domain.Festival; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; public record FestivalCreateRequest( - @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) { public Festival toEntity() { From 05acb9c2c24d9ef718a84a8176d3250bb55c17dd Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Tue, 26 Sep 2023 16:54:31 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor:=20TicketValidationRequest=20Not?= =?UTF-8?q?Null=20->=20NotBlank=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/festago/entry/dto/TicketValidationRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java b/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java index e8aeba744..49baadd6e 100644 --- a/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java +++ b/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java @@ -1,8 +1,8 @@ package com.festago.entry.dto; -import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; public record TicketValidationRequest( - @NotNull(message = "code 는 null 일 수 없습니다.") String code) { + @NotBlank(message = "code 는 공백일 수 없습니다.") String code) { } From 1943633c49e794cf49c8289aa7a4b592c190a3e5 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Tue, 26 Sep 2023 16:55:48 +0900 Subject: [PATCH 05/11] =?UTF-8?q?refactor:=20LoginRequest=20NotNull=20->?= =?UTF-8?q?=20NotBlank=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/com/festago/auth/dto/LoginRequest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/festago/auth/dto/LoginRequest.java b/backend/src/main/java/com/festago/auth/dto/LoginRequest.java index 8f82722aa..f418268e9 100644 --- a/backend/src/main/java/com/festago/auth/dto/LoginRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/LoginRequest.java @@ -1,10 +1,11 @@ package com.festago.auth.dto; import com.festago.auth.domain.SocialType; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; public record LoginRequest( @NotNull(message = "socialType 은 null 일 수 없습니다.") SocialType socialType, - @NotNull(message = "acessToken 은 null 일 수 없습니다.") String accessToken) { + @NotBlank(message = "acessToken 은 공백일 수 없습니다.") String accessToken) { } From c833ccc1052110be909b83e5dea05bdcdb5d945f Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Tue, 26 Sep 2023 17:01:16 +0900 Subject: [PATCH 06/11] =?UTF-8?q?feat:=20Request=20DTO=20Validation=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/festago/auth/dto/AdminLoginRequest.java | 6 ++++-- .../java/com/festago/auth/dto/AdminSignupRequest.java | 6 ++++-- .../com/festago/auth/dto/RootAdminInitializeRequest.java | 4 +++- .../java/com/festago/stage/dto/StageCreateRequest.java | 8 ++++++-- .../java/com/festago/ticket/dto/TicketCreateRequest.java | 5 ++++- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java b/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java index 1b71a7e8e..fcecc0c3e 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java @@ -1,8 +1,10 @@ package com.festago.auth.dto; +import jakarta.validation.constraints.NotBlank; + public record AdminLoginRequest( - String username, - String password + @NotBlank(message = "username은 공백일 수 없습니다.") String username, + @NotBlank(message = "password는 공백일 수 없습니다.") String password ) { } diff --git a/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java b/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java index b35cf7337..c1a165468 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java @@ -1,8 +1,10 @@ package com.festago.auth.dto; +import jakarta.validation.constraints.NotBlank; + public record AdminSignupRequest( - String username, - String password + @NotBlank(message = "username은 공백일 수 없습니다.") String username, + @NotBlank(message = "password은 공백일 수 없습니다.") String password ) { } diff --git a/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java b/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java index e1d408d89..f81e66591 100644 --- a/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java @@ -1,7 +1,9 @@ package com.festago.auth.dto; +import jakarta.validation.constraints.NotBlank; + public record RootAdminInitializeRequest( - String password + @NotBlank(message = "password는 공백일 수 없습니다.") String password ) { } diff --git a/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java b/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java index 00691a8db..ea990fb37 100644 --- a/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java +++ b/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java @@ -6,9 +6,13 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; public record StageCreateRequest( - @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime startTime, + @NotNull(message = "startTime은 null일 수 없습니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + LocalDateTime startTime, String lineUp, - @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime ticketOpenTime, + @NotNull(message = "ticketOpenTime은 null일 수 없습니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + LocalDateTime ticketOpenTime, @NotNull(message = "festivalId 는 null 일 수 없습니다.") Long festivalId) { } diff --git a/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java b/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java index 823bdca2b..086dbb340 100644 --- a/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java +++ b/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java @@ -10,6 +10,9 @@ public record TicketCreateRequest( @NotNull(message = "stageId 는 null 일 수 없습니다.") Long stageId, @NotNull(message = "ticketType 은 null 일 수 없습니다.") TicketType ticketType, @NotNull(message = "amount 는 null 일 수 없습니다.") Integer amount, - @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime entryTime) { + @NotNull(message = "entryTime은 null 일 수 없습니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + LocalDateTime entryTime +) { } From 0e23c971a9af6d67a152cd8334086e2bb3be7265 Mon Sep 17 00:00:00 2001 From: seokjin8678 Date: Sat, 30 Sep 2023 14:17:51 +0900 Subject: [PATCH 07/11] =?UTF-8?q?refactor:=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=9D=BC=EA=B4=84=EC=A0=81?= =?UTF-8?q?=EC=9D=B4=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/auth/dto/AdminSignupRequest.java | 2 +- .../java/com/festago/auth/dto/LoginRequest.java | 6 +++--- .../entry/dto/TicketValidationRequest.java | 2 +- .../festival/dto/FestivalCreateRequest.java | 15 ++++++--------- .../festago/school/dto/SchoolCreateRequest.java | 4 ++-- .../com/festago/stage/dto/StageCreateRequest.java | 10 +++------- .../festago/ticket/dto/TicketCreateRequest.java | 10 ++++------ .../festago/ticketing/dto/TicketingRequest.java | 2 +- 8 files changed, 21 insertions(+), 30 deletions(-) diff --git a/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java b/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java index c1a165468..69775db75 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java @@ -4,7 +4,7 @@ public record AdminSignupRequest( @NotBlank(message = "username은 공백일 수 없습니다.") String username, - @NotBlank(message = "password은 공백일 수 없습니다.") String password + @NotBlank(message = "password는 공백일 수 없습니다.") String password ) { } diff --git a/backend/src/main/java/com/festago/auth/dto/LoginRequest.java b/backend/src/main/java/com/festago/auth/dto/LoginRequest.java index da2695c56..46534d49a 100644 --- a/backend/src/main/java/com/festago/auth/dto/LoginRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/LoginRequest.java @@ -5,8 +5,8 @@ import jakarta.validation.constraints.NotNull; public record LoginRequest( - @NotNull(message = "socialType 은 null 일 수 없습니다.") SocialType socialType, - @NotBlank(message = "acessToken 은 공백일 수 없습니다.") String accessToken, - @NotNull(message = "fcmToken 은 null 일 수 없습니다.") String fcmToken) { + @NotNull(message = "socialType은 null 일 수 없습니다.") SocialType socialType, + @NotBlank(message = "acessToken은 공백일 수 없습니다.") String accessToken, + @NotNull(message = "fcmToken은 null 일 수 없습니다.") String fcmToken) { } diff --git a/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java b/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java index 49baadd6e..9d2a79343 100644 --- a/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java +++ b/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java @@ -3,6 +3,6 @@ import jakarta.validation.constraints.NotBlank; public record TicketValidationRequest( - @NotBlank(message = "code 는 공백일 수 없습니다.") String code) { + @NotBlank(message = "code는 공백일 수 없습니다.") String code) { } diff --git a/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java b/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java index b87a92db1..a965303ed 100644 --- a/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java +++ b/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java @@ -1,22 +1,19 @@ package com.festago.festival.dto; import com.festago.festival.domain.Festival; -import jakarta.validation.constraints.NotBlank; import com.festago.school.domain.School; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; 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) { + @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) { public Festival toEntity(School school) { if (thumbnail == null || thumbnail.isBlank()) { diff --git a/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java b/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java index 30312180c..36254422b 100644 --- a/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java +++ b/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java @@ -3,8 +3,8 @@ import jakarta.validation.constraints.NotNull; public record SchoolCreateRequest( - @NotNull(message = "name 은 null 일 수 없습니다.") String name, - @NotNull(message = "domain 은 null 일 수 없습니다.") String domain + @NotNull(message = "name은 null 일 수 없습니다.") String name, + @NotNull(message = "domain은 null 일 수 없습니다.") String domain ) { } diff --git a/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java b/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java index ea990fb37..1232c25cf 100644 --- a/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java +++ b/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java @@ -6,13 +6,9 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; public record StageCreateRequest( - @NotNull(message = "startTime은 null일 수 없습니다.") - @DateTimeFormat(iso = ISO.DATE_TIME) - LocalDateTime startTime, + @NotNull(message = "startTime은 null일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime startTime, String lineUp, - @NotNull(message = "ticketOpenTime은 null일 수 없습니다.") - @DateTimeFormat(iso = ISO.DATE_TIME) - LocalDateTime ticketOpenTime, - @NotNull(message = "festivalId 는 null 일 수 없습니다.") Long festivalId) { + @NotNull(message = "ticketOpenTime은 null일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime ticketOpenTime, + @NotNull(message = "festivalId는 null 일 수 없습니다.") Long festivalId) { } diff --git a/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java b/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java index 086dbb340..b6a02b963 100644 --- a/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java +++ b/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java @@ -7,12 +7,10 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; public record TicketCreateRequest( - @NotNull(message = "stageId 는 null 일 수 없습니다.") Long stageId, - @NotNull(message = "ticketType 은 null 일 수 없습니다.") TicketType ticketType, - @NotNull(message = "amount 는 null 일 수 없습니다.") Integer amount, - @NotNull(message = "entryTime은 null 일 수 없습니다.") - @DateTimeFormat(iso = ISO.DATE_TIME) - LocalDateTime entryTime + @NotNull(message = "stageId는 null 일 수 없습니다.") Long stageId, + @NotNull(message = "ticketType은 null 일 수 없습니다.") TicketType ticketType, + @NotNull(message = "amount는 null 일 수 없습니다.") Integer amount, + @NotNull(message = "entryTime은 null 일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime entryTime ) { } diff --git a/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java b/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java index a2fe08a38..f2a794215 100644 --- a/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java +++ b/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java @@ -3,6 +3,6 @@ import jakarta.validation.constraints.NotNull; public record TicketingRequest( - @NotNull(message = "ticketId 는 null 일 수 없습니다.") Long ticketId) { + @NotNull(message = "ticketId는 null 일 수 없습니다.") Long ticketId) { } From 3514c24c5395b868580142b42a1fc7ee5dea5760 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Mon, 2 Oct 2023 03:35:23 +0900 Subject: [PATCH 08/11] =?UTF-8?q?style:=20=EA=B0=9C=ED=96=89=20=EC=9D=BC?= =?UTF-8?q?=EA=B4=84=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/auth/dto/AdminLoginRequest.java | 6 ++++-- .../com/festago/auth/dto/AdminSignupRequest.java | 6 ++++-- .../java/com/festago/auth/dto/LoginRequest.java | 9 ++++++--- .../auth/dto/RootAdminInitializeRequest.java | 3 ++- .../festago/entry/dto/TicketValidationRequest.java | 4 +++- .../festival/dto/FestivalCreateRequest.java | 14 ++++++++++---- .../festago/school/dto/SchoolCreateRequest.java | 8 +++++--- .../com/festago/stage/dto/StageCreateRequest.java | 12 +++++++++--- .../student/dto/StudentSendMailRequest.java | 6 ++++-- .../student/dto/StudentVerificateRequest.java | 3 ++- .../festago/ticket/dto/TicketCreateRequest.java | 13 +++++++++---- .../festago/ticketing/dto/TicketingRequest.java | 4 +++- 12 files changed, 61 insertions(+), 27 deletions(-) diff --git a/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java b/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java index fcecc0c3e..313977f5c 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminLoginRequest.java @@ -3,8 +3,10 @@ import jakarta.validation.constraints.NotBlank; public record AdminLoginRequest( - @NotBlank(message = "username은 공백일 수 없습니다.") String username, - @NotBlank(message = "password는 공백일 수 없습니다.") String password + @NotBlank(message = "username은 공백일 수 없습니다.") + String username, + @NotBlank(message = "password는 공백일 수 없습니다.") + String password ) { } diff --git a/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java b/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java index 69775db75..02c689d9f 100644 --- a/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/AdminSignupRequest.java @@ -3,8 +3,10 @@ import jakarta.validation.constraints.NotBlank; public record AdminSignupRequest( - @NotBlank(message = "username은 공백일 수 없습니다.") String username, - @NotBlank(message = "password는 공백일 수 없습니다.") String password + @NotBlank(message = "username은 공백일 수 없습니다.") + String username, + @NotBlank(message = "password는 공백일 수 없습니다.") + String password ) { } diff --git a/backend/src/main/java/com/festago/auth/dto/LoginRequest.java b/backend/src/main/java/com/festago/auth/dto/LoginRequest.java index 46534d49a..5872e77e1 100644 --- a/backend/src/main/java/com/festago/auth/dto/LoginRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/LoginRequest.java @@ -5,8 +5,11 @@ import jakarta.validation.constraints.NotNull; public record LoginRequest( - @NotNull(message = "socialType은 null 일 수 없습니다.") SocialType socialType, - @NotBlank(message = "acessToken은 공백일 수 없습니다.") String accessToken, - @NotNull(message = "fcmToken은 null 일 수 없습니다.") String fcmToken) { + @NotNull(message = "socialType은 null 일 수 없습니다.") + SocialType socialType, + @NotBlank(message = "acessToken은 공백일 수 없습니다.") + String accessToken, + @NotBlank(message = "fcmToken은 공백일 수 없습니다.") + String fcmToken) { } diff --git a/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java b/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java index f81e66591..1f76a2921 100644 --- a/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java +++ b/backend/src/main/java/com/festago/auth/dto/RootAdminInitializeRequest.java @@ -3,7 +3,8 @@ import jakarta.validation.constraints.NotBlank; public record RootAdminInitializeRequest( - @NotBlank(message = "password는 공백일 수 없습니다.") String password + @NotBlank(message = "password는 공백일 수 없습니다.") + String password ) { } diff --git a/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java b/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java index 9d2a79343..c006b24e6 100644 --- a/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java +++ b/backend/src/main/java/com/festago/entry/dto/TicketValidationRequest.java @@ -3,6 +3,8 @@ import jakarta.validation.constraints.NotBlank; public record TicketValidationRequest( - @NotBlank(message = "code는 공백일 수 없습니다.") String code) { + @NotBlank(message = "code는 공백일 수 없습니다.") + String code +) { } diff --git a/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java b/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java index a965303ed..3fe810347 100644 --- a/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java +++ b/backend/src/main/java/com/festago/festival/dto/FestivalCreateRequest.java @@ -9,11 +9,17 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; 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, + @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) { public Festival toEntity(School school) { if (thumbnail == null || thumbnail.isBlank()) { diff --git a/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java b/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java index 36254422b..cef320d8e 100644 --- a/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java +++ b/backend/src/main/java/com/festago/school/dto/SchoolCreateRequest.java @@ -1,10 +1,12 @@ package com.festago.school.dto; -import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.NotBlank; public record SchoolCreateRequest( - @NotNull(message = "name은 null 일 수 없습니다.") String name, - @NotNull(message = "domain은 null 일 수 없습니다.") String domain + @NotBlank(message = "name은 공백일 수 없습니다.") + String name, + @NotBlank(message = "domain은 공백일 수 없습니다.") + String domain ) { } diff --git a/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java b/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java index 1232c25cf..850a43242 100644 --- a/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java +++ b/backend/src/main/java/com/festago/stage/dto/StageCreateRequest.java @@ -6,9 +6,15 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; public record StageCreateRequest( - @NotNull(message = "startTime은 null일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime startTime, + @NotNull(message = "startTime은 null일 수 없습니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + LocalDateTime startTime, String lineUp, - @NotNull(message = "ticketOpenTime은 null일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime ticketOpenTime, - @NotNull(message = "festivalId는 null 일 수 없습니다.") Long festivalId) { + @NotNull(message = "ticketOpenTime은 null일 수 없습니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + LocalDateTime ticketOpenTime, + @NotNull(message = "festivalId는 null 일 수 없습니다.") + Long festivalId +) { } diff --git a/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java b/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java index fd7c76ae8..fcb0563cf 100644 --- a/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java +++ b/backend/src/main/java/com/festago/student/dto/StudentSendMailRequest.java @@ -4,8 +4,10 @@ import jakarta.validation.constraints.NotNull; public record StudentSendMailRequest( - @NotBlank(message = "username은 공백일 수 없습니다.") String username, - @NotNull(message = "schoolId는 null 일 수 없습니다.") Long schoolId + @NotBlank(message = "username은 공백일 수 없습니다.") + String username, + @NotNull(message = "schoolId는 null 일 수 없습니다.") + Long schoolId ) { } diff --git a/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java b/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java index 4cf000f92..32a3a198f 100644 --- a/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java +++ b/backend/src/main/java/com/festago/student/dto/StudentVerificateRequest.java @@ -3,7 +3,8 @@ import jakarta.validation.constraints.NotBlank; public record StudentVerificateRequest( - @NotBlank(message = "code는 공백일 수 없습니다.") String code + @NotBlank(message = "code는 공백일 수 없습니다.") + String code ) { } diff --git a/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java b/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java index b6a02b963..31d740a08 100644 --- a/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java +++ b/backend/src/main/java/com/festago/ticket/dto/TicketCreateRequest.java @@ -7,10 +7,15 @@ import org.springframework.format.annotation.DateTimeFormat.ISO; public record TicketCreateRequest( - @NotNull(message = "stageId는 null 일 수 없습니다.") Long stageId, - @NotNull(message = "ticketType은 null 일 수 없습니다.") TicketType ticketType, - @NotNull(message = "amount는 null 일 수 없습니다.") Integer amount, - @NotNull(message = "entryTime은 null 일 수 없습니다.") @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime entryTime + @NotNull(message = "stageId는 null 일 수 없습니다.") + Long stageId, + @NotNull(message = "ticketType은 null 일 수 없습니다.") + TicketType ticketType, + @NotNull(message = "amount는 null 일 수 없습니다.") + Integer amount, + @NotNull(message = "entryTime은 null 일 수 없습니다.") + @DateTimeFormat(iso = ISO.DATE_TIME) + LocalDateTime entryTime ) { } diff --git a/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java b/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java index f2a794215..94f2e7a68 100644 --- a/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java +++ b/backend/src/main/java/com/festago/ticketing/dto/TicketingRequest.java @@ -3,6 +3,8 @@ import jakarta.validation.constraints.NotNull; public record TicketingRequest( - @NotNull(message = "ticketId는 null 일 수 없습니다.") Long ticketId) { + @NotNull(message = "ticketId는 null 일 수 없습니다.") + Long ticketId +) { } From b9389d1375d8e03b8faaba4d0ed68f60382ba3d5 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Mon, 2 Oct 2023 03:36:41 +0900 Subject: [PATCH 09/11] =?UTF-8?q?refactor:=20Controller=EC=9D=98=20Request?= =?UTF-8?q?=20Body=20@Valid=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/festago/presentation/AuthController.java | 3 ++- .../main/java/com/festago/presentation/StudentController.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/festago/presentation/AuthController.java b/backend/src/main/java/com/festago/presentation/AuthController.java index 36038cdbf..5338b1983 100644 --- a/backend/src/main/java/com/festago/presentation/AuthController.java +++ b/backend/src/main/java/com/festago/presentation/AuthController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -30,7 +31,7 @@ public AuthController(AuthFacadeService authFacadeService, MemberFCMService memb @PostMapping("/oauth2") @Operation(description = "소셜 엑세스 토큰을 기반으로 로그인 요청을 보낸다.", summary = "OAuth2 로그인") - public ResponseEntity login(@RequestBody LoginRequest request) { + public ResponseEntity login(@RequestBody @Valid LoginRequest request) { LoginResponse response = authFacadeService.login(request.socialType(), request.accessToken()); memberFCMService.saveMemberFCM(response.accessToken(), request.fcmToken()); return ResponseEntity.ok() diff --git a/backend/src/main/java/com/festago/presentation/StudentController.java b/backend/src/main/java/com/festago/presentation/StudentController.java index d0f397f92..20cb7c4e4 100644 --- a/backend/src/main/java/com/festago/presentation/StudentController.java +++ b/backend/src/main/java/com/festago/presentation/StudentController.java @@ -27,7 +27,7 @@ public StudentController(StudentService studentService) { @PostMapping("/send-verification") @Operation(description = "학교 인증 이메일을 전송한다.", summary = "학생 인증 이메일 전송") public ResponseEntity sendEmail(@Member Long memberId, - @RequestBody StudentSendMailRequest request) { + @RequestBody @Valid StudentSendMailRequest request) { studentService.sendVerificationMail(memberId, request); return ResponseEntity.ok() .build(); From 0febe775ede0a370a99b465e33da5eac616ab78b Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Mon, 2 Oct 2023 03:40:27 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor:=20=EC=83=81=EC=88=98=20?= =?UTF-8?q?=EC=98=A4=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/common/exception/dto/ErrorResponse.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java b/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java index 7c58f746e..12c67b4e3 100644 --- a/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java +++ b/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java @@ -6,9 +6,10 @@ public record ErrorResponse( ErrorCode errorCode, - String message) { + String message +) { - private static final String NOT_CUSTOM_EXCPETION = "Validation failed"; + private static final String NOT_CUSTOM_EXCEPTION = "Validation failed"; public static ErrorResponse from(FestaGoException festaGoException) { return ErrorResponse.from(festaGoException.getErrorCode()); @@ -19,7 +20,7 @@ public static ErrorResponse from(ErrorCode errorCode) { } public static ErrorResponse from(ErrorCode errorCode, MethodArgumentNotValidException e) { - if (e.getMessage().startsWith(NOT_CUSTOM_EXCPETION)) { + if (e.getMessage().startsWith(NOT_CUSTOM_EXCEPTION)) { return new ErrorResponse(errorCode, errorCode.getMessage()); } return new ErrorResponse(errorCode, e.getMessage()); From d4a0c7b6b229384441a7397c076c0d42cad787a7 Mon Sep 17 00:00:00 2001 From: xxeol2 Date: Mon, 2 Oct 2023 03:47:19 +0900 Subject: [PATCH 11/11] =?UTF-8?q?refactor:=20Validation=20Error=20?= =?UTF-8?q?=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=9E=90=EC=84=B8=ED=95=98?= =?UTF-8?q?=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/festago/common/exception/dto/ErrorResponse.java | 8 +++++++- .../com/festago/presentation/GlobalExceptionHandler.java | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java b/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java index 12c67b4e3..a15d330fc 100644 --- a/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java +++ b/backend/src/main/java/com/festago/common/exception/dto/ErrorResponse.java @@ -2,6 +2,8 @@ import com.festago.common.exception.ErrorCode; import com.festago.common.exception.FestaGoException; +import java.util.List; +import org.springframework.validation.FieldError; import org.springframework.web.bind.MethodArgumentNotValidException; public record ErrorResponse( @@ -20,9 +22,13 @@ public static ErrorResponse from(ErrorCode errorCode) { } public static ErrorResponse from(ErrorCode errorCode, MethodArgumentNotValidException e) { - if (e.getMessage().startsWith(NOT_CUSTOM_EXCEPTION)) { + List fieldErrors = e.getBindingResult().getFieldErrors(); + if (fieldErrors.isEmpty()) { return new ErrorResponse(errorCode, errorCode.getMessage()); } + if (e.getMessage().startsWith(NOT_CUSTOM_EXCEPTION)) { + return new ErrorResponse(errorCode, fieldErrors.get(0).getDefaultMessage()); + } return new ErrorResponse(errorCode, e.getMessage()); } } diff --git a/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java b/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java index 1bc3b023b..9629a8b2c 100644 --- a/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java +++ b/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java @@ -104,10 +104,11 @@ public ResponseEntity handle(Exception e, HttpServletRequest requ } @Override - protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException e, HttpHeaders headers, + protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException e, + HttpHeaders headers, HttpStatusCode status, WebRequest request) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) - .body(ErrorResponse.from(ErrorCode.INVALID_REQUEST_ARGUMENT)); + .body(ErrorResponse.from(ErrorCode.INVALID_REQUEST_ARGUMENT, e)); } private void logInfo(FestaGoException e, HttpServletRequest request) {