-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/post-search-tag
- Loading branch information
Showing
22 changed files
with
215 additions
and
71 deletions.
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
src/main/java/balancetalk/global/exception/ConstraintExceptionHandler.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
src/main/java/balancetalk/global/exception/ConstraintViolationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package balancetalk.global.exception; | ||
|
||
import jakarta.validation.ConstraintViolation; | ||
import jakarta.validation.ConstraintViolationException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class ConstraintViolationHandler { | ||
|
||
@ExceptionHandler(ConstraintViolationException.class) | ||
public ResponseEntity<Object> handleConstraintViolationException(ConstraintViolationException e) { | ||
Map<Object, Object> errors = new HashMap<>(); | ||
Set<ConstraintViolation<?>> violations = e.getConstraintViolations(); | ||
String errorMessage = violations.stream() | ||
.map(violation -> violation.getMessage()) | ||
.collect(Collectors.joining(", ")); | ||
errors.put("message" , errorMessage); | ||
log.info("errorMessage={}", errorMessage); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errors); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/balancetalk/global/exception/MethodArgumentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package balancetalk.global.exception; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.FieldError; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class MethodArgumentException { | ||
@ExceptionHandler(MethodArgumentNotValidException.class) | ||
public ResponseEntity<Object> handleNoticeTitleSizeExceededExceptions(MethodArgumentNotValidException e) { | ||
Map<Object, Object> errors = new HashMap<>(); | ||
FieldError fieldError = e.getBindingResult().getFieldError(); | ||
String errorMessage = fieldError.getDefaultMessage(); | ||
errors.put("message" , errorMessage); | ||
log.info("errorMessage={}", errorMessage); | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
@@ -11,7 +13,9 @@ | |
@NoArgsConstructor | ||
public class EmailRequest { | ||
|
||
@NotNull | ||
@Size(max = 30) | ||
@Email(regexp = "^[a-zA-Z0-9._%+-]{1,20}@[a-zA-Z0-9.-]{1,10}\\.[a-zA-Z]{2,}$") | ||
@Schema(description = "인증 번호를 받을 이메일 주소", example = "[email protected]") | ||
private String email; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
@@ -11,7 +13,9 @@ | |
@NoArgsConstructor | ||
public class EmailVerification { | ||
|
||
@NotNull | ||
@Size(max = 30) | ||
@Email(regexp = "^[a-zA-Z0-9._%+-]{1,20}@[a-zA-Z0-9.-]{1,10}\\.[a-zA-Z]{2,}$") | ||
@Schema(description = "인증 번호를 검증할 이메일 주소", example = "[email protected]") | ||
private String email; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,7 @@ | |
import balancetalk.module.member.domain.Member; | ||
import balancetalk.module.member.domain.Role; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
import jakarta.validation.constraints.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
@@ -18,9 +16,14 @@ | |
@AllArgsConstructor | ||
public class JoinRequest { | ||
|
||
@NotBlank | ||
@Size(min = 2, max = 10) | ||
@Schema(description = "회원 닉네임", example = "닉네임") | ||
private String nickname; | ||
|
||
@NotNull | ||
@Size(max = 30) | ||
@Email(regexp = "^[a-zA-Z0-9._%+-]{1,20}@[a-zA-Z0-9.-]{1,10}\\.[a-zA-Z]{2,}$") | ||
@Schema(description = "회원 이메일", example = "[email protected]") | ||
private String email; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.