-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor : 각 Entity에 맞는 success, error 코드 추가 및 적용 #90
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package naughty.tuzamate.domain.comment.code; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import naughty.tuzamate.global.error.BaseErrorCode; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @AllArgsConstructor | ||
| @Getter | ||
| public enum CommentErrorCode implements BaseErrorCode { | ||
|
|
||
| COMMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "COMMENT404", "댓글이 존재하지 않습니다."),; | ||
|
|
||
| private final HttpStatus status; | ||
| private final String code; | ||
| private final String message; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package naughty.tuzamate.domain.notification.code; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import naughty.tuzamate.global.error.BaseErrorCode; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @AllArgsConstructor | ||
| @Getter | ||
| public enum NotificationErrorCode implements BaseErrorCode { | ||
|
|
||
| NOTIFICATION_NOT_FOUND(HttpStatus.NOT_FOUND, "NOTIFICATIONT404", "알림이 존재하지 않습니다."),; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private final HttpStatus status; | ||
| private final String code; | ||
| private final String message; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package naughty.tuzamate.domain.post.code; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import naughty.tuzamate.global.error.BaseErrorCode; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @AllArgsConstructor | ||
| @Getter | ||
| public enum PostErrorCode implements BaseErrorCode { | ||
|
|
||
| POST_NOT_FOUND(HttpStatus.NOT_FOUND, "POST404", "게시글이 존재하지 않습니다."),; | ||
|
|
||
| private final HttpStatus status; | ||
| private final String code; | ||
| private final String message; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package naughty.tuzamate.domain.post.code; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import naughty.tuzamate.global.success.BaseSuccessCode; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @AllArgsConstructor | ||
| @Getter | ||
| public enum PostSuccessCode implements BaseSuccessCode { | ||
|
|
||
| POST_OK(HttpStatus.OK, "200", "게시글 조회에 성공했습니다."), | ||
|
|
||
| POST_CREATED(HttpStatus.CREATED, "201", "게시글이 생성되었습니다."), | ||
|
|
||
| DELETED(HttpStatus.NO_CONTENT, "204", "성공적으로 삭제되었습니다."); | ||
|
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify controller usage and 204 semantics. Ensure PostController consistently returns PostSuccessCode and that 204 (DELETED) responses don’t include a body. Run to verify usages and check for any remaining GeneralSuccessCode references in post controllers: 🏁 Script executed: #!/bin/bash
# Find usages of PostSuccessCode and any remaining GeneralSuccessCode in post controllers
rg -n -C2 -g '!**/build/**' -g '!**/out/**' 'PostSuccessCode|GeneralSuccessCode' --type=java | rg -n -C2 'PostController|post'Length of output: 9693 Align PostController Success Codes & 204 Semantics – The Please update these endpoints to use the appropriate 🤖 Prompt for AI Agents |
||
|
|
||
| private final HttpStatus status; | ||
| private final String code; | ||
| private final String message; | ||
| } | ||
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.
Validate that parent comment belongs to the same post to prevent cross-post replies.
Without this check, a reply can be attached to a parent from a different post, creating inconsistent data.
Apply this diff:
if (reqDTO.parentId() != null) { parent = commentRepository.findById(reqDTO.parentId()) .orElseThrow(() -> new CustomException(CommentErrorCode.COMMENT_NOT_FOUND)); + // Ensure the parent comment belongs to the same post + if (!parent.getPost().getId().equals(postId)) { + throw new CustomException(GeneralErrorCode.BAD_REQUEST_400); + } }📝 Committable suggestion
🤖 Prompt for AI Agents