-
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.
* refactor(OAuthInfoService): EnumMap으로 변경 * refactor(SessionInterceptor): CORS 요청 허용 분기는 CorsUtils를 사용하도록 변경 * feat(GlobalExceptionHandler): 전역 예외처리 로직 및 비즈니스 예외 구현 * refactor(ApiResponse): 예외 발생 시 커스텀 응답 구현 * feat(CommentErrorCode): 댓글 도메인 비즈니스 예외 적용 * refactor(CommentService): 메서드 분리 리펙터링 * feat(CommentService): 댓글 페이지네이션 정렬방식 비즈니스 예외 추가 * refactor(MemberService): 코드 간략화 - DTO to Entity는 생성자를 이용해 간략화 - OAuthInfo 응답 인터페이스 내부 default 메서드를 구현해 코드 간략화 * feat(MemberErrorCode): 회원 도메인 비즈니스 예외 적용 * refactor: memberRepository의존성을 memberService로 변경 후 중복 코드 제거 - `findMemberByIdOrThrow` 메서드로 중복 코드 제거 * feat(NotificationErrorCode): 알림 도메인 비즈니스 예외 적용 * refactor: 메서드 분리 및 lombok 적용으로 리펙터링
- Loading branch information
1 parent
aea91bd
commit d44b048
Showing
30 changed files
with
454 additions
and
116 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/econo/buddybridge/auth/dto/OAuthInfoResponse.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 |
---|---|---|
@@ -1,10 +1,26 @@ | ||
package econo.buddybridge.auth.dto; | ||
|
||
import econo.buddybridge.member.entity.DisabilityType; | ||
import econo.buddybridge.member.entity.Gender; | ||
import econo.buddybridge.member.entity.Member; | ||
|
||
public interface OAuthInfoResponse { | ||
String getEmail(); | ||
String getName(); | ||
String getNickname(); | ||
Integer getAge(); | ||
String getGender(); | ||
String getProfileImageUrl(); | ||
|
||
default Member toMember() { | ||
return Member.builder() | ||
.email(getEmail()) | ||
.name(getName()) | ||
.nickname(getNickname()) | ||
.age(getAge()) | ||
.gender(Gender.fromEnglishName(getGender())) | ||
.profileImageUrl(getProfileImageUrl()) | ||
.disabilityType(DisabilityType.없음) // 회원가입 시 초기 장애 유형은 없음으로 설정 | ||
.build(); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/econo/buddybridge/comment/exception/CommentDeleteNotAllowedException.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,13 @@ | ||
package econo.buddybridge.comment.exception; | ||
|
||
import econo.buddybridge.common.exception.BusinessException; | ||
|
||
public class CommentDeleteNotAllowedException extends BusinessException { | ||
|
||
public static BusinessException EXCEPTION = new CommentDeleteNotAllowedException(); | ||
|
||
private CommentDeleteNotAllowedException() { | ||
super(CommentErrorCode.COMMENT_DELETE_NOT_ALLOWED); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/econo/buddybridge/comment/exception/CommentErrorCode.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,37 @@ | ||
package econo.buddybridge.comment.exception; | ||
|
||
import econo.buddybridge.common.exception.ErrorCode; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public enum CommentErrorCode implements ErrorCode { | ||
COMMENT_NOT_FOUND("C001", HttpStatus.NOT_FOUND, "존재하지 않는 댓글입니다."), | ||
COMMENT_UPDATE_NOT_ALLOWED("C002", HttpStatus.FORBIDDEN, "본인의 댓글만 수정할 수 있습니다."), | ||
COMMENT_DELETE_NOT_ALLOWED("C003", HttpStatus.FORBIDDEN, "본인의 댓글만 삭제할 수 있습니다."), | ||
COMMENT_INVALID_DIRECTION("C004", HttpStatus.BAD_REQUEST, "올바르지 않은 정렬 방식입니다."), | ||
; | ||
|
||
private final String code; | ||
private final HttpStatus httpStatus; | ||
private final String message; | ||
|
||
CommentErrorCode(String code, HttpStatus httpStatus, String message) { | ||
this.code = code; | ||
this.httpStatus = httpStatus; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/econo/buddybridge/comment/exception/CommentInvalidDirectionException.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,13 @@ | ||
package econo.buddybridge.comment.exception; | ||
|
||
import econo.buddybridge.common.exception.BusinessException; | ||
|
||
public class CommentInvalidDirectionException extends BusinessException { | ||
|
||
public static BusinessException EXCEPTION = new CommentInvalidDirectionException(); | ||
|
||
private CommentInvalidDirectionException() { | ||
super(CommentErrorCode.COMMENT_INVALID_DIRECTION); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/econo/buddybridge/comment/exception/CommentNotFoundException.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,12 @@ | ||
package econo.buddybridge.comment.exception; | ||
|
||
import econo.buddybridge.common.exception.BusinessException; | ||
|
||
public class CommentNotFoundException extends BusinessException { | ||
|
||
public static BusinessException EXCEPTION = new CommentNotFoundException(); | ||
|
||
private CommentNotFoundException() { | ||
super(CommentErrorCode.COMMENT_NOT_FOUND); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/econo/buddybridge/comment/exception/CommentUpdateNotAllowedException.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,13 @@ | ||
package econo.buddybridge.comment.exception; | ||
|
||
import econo.buddybridge.common.exception.BusinessException; | ||
|
||
public class CommentUpdateNotAllowedException extends BusinessException { | ||
|
||
public static BusinessException EXCEPTION = new CommentUpdateNotAllowedException(); | ||
|
||
private CommentUpdateNotAllowedException() { | ||
super(CommentErrorCode.COMMENT_UPDATE_NOT_ALLOWED); | ||
} | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/econo/buddybridge/common/exception/BusinessException.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,15 @@ | ||
package econo.buddybridge.common.exception; | ||
|
||
public class BusinessException extends RuntimeException { | ||
|
||
private final ErrorCode errorCode; | ||
|
||
public BusinessException(ErrorCode errorCode) { | ||
super(errorCode.getMessage()); | ||
this.errorCode = errorCode; | ||
} | ||
|
||
public ErrorCode getErrorCode() { | ||
return errorCode; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/econo/buddybridge/common/exception/CommonErrorCode.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,33 @@ | ||
package econo.buddybridge.common.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public enum CommonErrorCode implements ErrorCode { | ||
INVALID_INPUT_VALUE("C001", HttpStatus.BAD_REQUEST, "요청 값이 잘못되었습니다."), | ||
; | ||
|
||
private final String code; | ||
private final HttpStatus httpStatus; | ||
private final String message; | ||
|
||
CommonErrorCode(String code, HttpStatus httpStatus, String message) { | ||
this.code = code; | ||
this.httpStatus = httpStatus; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public String getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public HttpStatus getHttpStatus() { | ||
return httpStatus; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return message; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/econo/buddybridge/common/exception/ErrorCode.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,10 @@ | ||
package econo.buddybridge.common.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public interface ErrorCode { | ||
|
||
String getCode(); | ||
HttpStatus getHttpStatus(); | ||
String getMessage(); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/econo/buddybridge/common/exception/ErrorResponse.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,24 @@ | ||
package econo.buddybridge.common.exception; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.util.List; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
public class ErrorResponse { | ||
|
||
private final String code; | ||
private final int status; | ||
private final String message; | ||
|
||
@Setter | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
private List<ValidationError> invalidParams; | ||
|
||
public ErrorResponse(ErrorCode errorCode) { | ||
this.code = errorCode.getCode(); | ||
this.status = errorCode.getHttpStatus().value(); | ||
this.message = errorCode.getMessage(); | ||
} | ||
} |
Oops, something went wrong.