-
Notifications
You must be signed in to change notification settings - Fork 3
[refactor] Mapper에서 NPE 요소 제거하기 + 커스텀 예외 적용하기 #56
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
43ac5e2
:recycle: refactor : 예외 코드 적용, NPE 방지, 조건문 오류 수정
silver-eunjoo 12cfc7b
chore: Java 스타일 수정
2207861
:wrench: chore : 설정파일에 최대 파일 크기 설정
silver-eunjoo e38579d
chore: Java 스타일 수정
0244f4a
:sparkles: feat: 페이징 예외 적용
silver-eunjoo eb0d3a0
chore: Java 스타일 수정
96525ff
:wrench: chore: 시큐리티 임시 허용 해제
silver-eunjoo cc35521
:recycle: refactor : 메서드 Quiz 내부로 리팩토링
silver-eunjoo e57ae31
:recycle: refactor : PR 리뷰 반영 (탈퇴한 사용자 표시)
silver-eunjoo 576961c
:recycle: refactor : 메서드 명 수정
silver-eunjoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -50,7 +50,7 @@ public class Quiz extends BaseEntity { | |
| private String thumbnailUrl; | ||
|
|
||
| @ManyToOne | ||
| @JoinColumn(name = "creator_id") | ||
| @JoinColumn(name = "creator_id", nullable = true) | ||
| private User creator; | ||
|
|
||
| public Quiz( | ||
|
|
@@ -81,4 +81,20 @@ public void changeDescription(String description) { | |
| public void changeThumbnailUrl(String thumbnailUrl) { | ||
| this.thumbnailUrl = thumbnailUrl; | ||
| } | ||
|
|
||
| public Long getUserIdIfExists() { | ||
| if (this.creator == null) { | ||
| return null; | ||
| } | ||
|
|
||
| return this.creator.getId(); | ||
| } | ||
|
|
||
| public String getUserNicknameIfExists() { | ||
|
||
| if (this.creator == null) { | ||
| return "탈퇴한 사용자"; | ||
| } | ||
|
|
||
| return this.creator.getNickname(); | ||
| } | ||
| } | ||
This file contains hidden or 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
18 changes: 18 additions & 0 deletions
18
backend/src/main/java/io/f1/backend/global/exception/errorcode/GameErrorCode.java
This file contains hidden or 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,18 @@ | ||
| package io.f1.backend.global.exception.errorcode; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum GameErrorCode implements ErrorCode { | ||
| GAME_SETTING_CONFLICT("E409002", HttpStatus.CONFLICT, "게임 설정이 맞지 않습니다."); | ||
|
|
||
| private final String code; | ||
|
|
||
| private final HttpStatus httpStatus; | ||
|
|
||
| private final String message; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[L5-참고의견]
메서드명에 IfExists는 제외하고 Optional을 return 해주는 것도 하나의 방법일 것 같습니다.
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.
추가로, UserId 대신 CreatorId가 의미 전달에 효과적일 수 있을 것 같습니다.
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.
옹 ! 메서드명 둘 다
Creator로 변경했습니다 ! 또한,IfExists보다, 확실하게 값이 있을지 없을지 모른다는 느낌으로 get보다는 find가 맞을 것 같아findCreatorId로 메서드명 변경했습니다 ! 좋은 의견 감사합니다 !! :)