-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 예외 처리 핸들러 추가 * feat: Offering 예외 처리 코드 추가 * feat: Comment 예외 처리 코드 추가 * feat: Member 예외 처리 코드 추가 * feat: OfferingMember 예외 처리 코드 추가 * feat: Offering 예외 처리 상세 코드 추가 * feat: 에러 코드 적용 * feat: 도메인 검증 로직 * feat: DTO 검증 로직 --------- Co-authored-by: masonkimseoul <masonkimseoul@gmail.com>
- Loading branch information
1 parent
6b7ab72
commit 7a9d176
Showing
16 changed files
with
193 additions
and
16 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
backend/src/main/java/com/zzang/chongdae/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,24 @@ | ||
package com.zzang.chongdae.comment.exception; | ||
|
||
import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||
|
||
import com.zzang.chongdae.global.exception.ErrorMessage; | ||
import com.zzang.chongdae.global.exception.ErrorResponse; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum CommentErrorCode implements ErrorResponse { | ||
|
||
NOT_FOUND(BAD_REQUEST, "해당 댓글이 존재하지 않습니다."); | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public ErrorMessage getErrorMessage() { | ||
return new ErrorMessage(this.message); | ||
} | ||
} |
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
14 changes: 13 additions & 1 deletion
14
backend/src/main/java/com/zzang/chongdae/comment/service/dto/CommentSaveRequest.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,4 +1,16 @@ | ||
package com.zzang.chongdae.comment.service.dto; | ||
|
||
public record CommentSaveRequest(Long memberId, Long offeringId, String content) { | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record CommentSaveRequest(@NotNull | ||
Long memberId, | ||
|
||
@NotNull | ||
Long offeringId, | ||
|
||
@NotBlank(message = "댓글 내용을 입력해주세요.") | ||
@Size(max = 80, message = "댓글 내용의 길이를 확인해주세요.") | ||
String content) { | ||
} |
4 changes: 4 additions & 0 deletions
4
backend/src/main/java/com/zzang/chongdae/global/exception/ErrorMessage.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,4 @@ | ||
package com.zzang.chongdae.global.exception; | ||
|
||
public record ErrorMessage(String value) { | ||
} |
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/com/zzang/chongdae/global/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,10 @@ | ||
package com.zzang.chongdae.global.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public interface ErrorResponse { | ||
|
||
HttpStatus getStatus(); | ||
|
||
ErrorMessage getErrorMessage(); | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/com/zzang/chongdae/global/exception/GlobalExceptionHandler.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,17 @@ | ||
package com.zzang.chongdae.global.exception; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ErrorMessage> handle(MarketException e) { | ||
ErrorResponse errorResponse = e.getErrorResponse(); | ||
return ResponseEntity | ||
.status(errorResponse.getStatus()) | ||
.body(errorResponse.getErrorMessage()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/zzang/chongdae/global/exception/MarketException.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,11 @@ | ||
package com.zzang.chongdae.global.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class MarketException extends RuntimeException { | ||
|
||
private final ErrorResponse errorResponse; | ||
} |
24 changes: 24 additions & 0 deletions
24
backend/src/main/java/com/zzang/chongdae/member/exception/MemberErrorCode.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 com.zzang.chongdae.member.exception; | ||
|
||
import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||
|
||
import com.zzang.chongdae.global.exception.ErrorMessage; | ||
import com.zzang.chongdae.global.exception.ErrorResponse; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum MemberErrorCode implements ErrorResponse { | ||
|
||
NOT_FOUND(BAD_REQUEST, "해당 사용자가 존재하지 않습니다."); | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public ErrorMessage getErrorMessage() { | ||
return new ErrorMessage(this.message); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/com/zzang/chongdae/offering/exception/OfferingErrorCode.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,27 @@ | ||
package com.zzang.chongdae.offering.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||
|
||
import com.zzang.chongdae.global.exception.ErrorMessage; | ||
import com.zzang.chongdae.global.exception.ErrorResponse; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum OfferingErrorCode implements ErrorResponse { | ||
|
||
NOT_FOUND(BAD_REQUEST, "해당 공모가 존재하지 않습니다."), | ||
PARTICIPANT_FULL(BAD_REQUEST, "해당 공모에 참여 가능한 인원수를 초과하였습니다."), | ||
CANNOT_PARTICIPATE(BAD_REQUEST, "참여할 수 없는 공모입니다."); | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public ErrorMessage getErrorMessage() { | ||
return new ErrorMessage(this.message); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...nd/src/main/java/com/zzang/chongdae/offeringmember/exception/OfferingMemberErrorCode.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 com.zzang.chongdae.offeringmember.exception; | ||
|
||
import static org.springframework.http.HttpStatus.BAD_REQUEST; | ||
|
||
import com.zzang.chongdae.global.exception.ErrorMessage; | ||
import com.zzang.chongdae.global.exception.ErrorResponse; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum OfferingMemberErrorCode implements ErrorResponse { | ||
|
||
DUPLICATED(BAD_REQUEST, "이미 참여한 공모엔 참여할 수 없습니다."); | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public ErrorMessage getErrorMessage() { | ||
return new ErrorMessage(this.message); | ||
} | ||
} |
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
8 changes: 7 additions & 1 deletion
8
...end/src/main/java/com/zzang/chongdae/offeringmember/service/dto/ParticipationRequest.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,4 +1,10 @@ | ||
package com.zzang.chongdae.offeringmember.service.dto; | ||
|
||
public record ParticipationRequest(Long memberId, Long offeringId) { | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record ParticipationRequest(@NotNull | ||
Long memberId, | ||
|
||
@NotNull | ||
Long offeringId) { | ||
} |