-
Notifications
You must be signed in to change notification settings - Fork 13
[Spring Core] 여경현 과제 제출합니다. #12
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
Open
yeokyunghyun
wants to merge
11
commits into
BCSDLab-Edu:main
Choose a base branch
from
yeokyunghyun:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6116f69
feat : 게시물, 멤버, 게시판 조회 예외 기능 완성
yeokyunghyun 41b6bbc
feat : 생성 예외처리
yeokyunghyun 90dab41
feat : 삭제 예외처리
yeokyunghyun 9b5395a
feat : MemberRepositoryJpa 추가
yeokyunghyun a9a0148
feat : BoardRepositoryJpa추가
yeokyunghyun 2d2f9c6
feat : ArticleRepositoryJpa 추가
yeokyunghyun 6e2c68a
feat : EntityManager을 이용한 JPA로 변환
yeokyunghyun 0d243a7
feat : BoardRepository 변경
yeokyunghyun 0d6aabf
feat : MemberRepository 변경
yeokyunghyun ee82afd
feat : ArticleRepository 변경
yeokyunghyun 3d94143
feat : 영속성 전이 추가
yeokyunghyun 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
11 changes: 7 additions & 4 deletions
11
src/main/java/com/example/demo/controller/dto/request/ArticleCreateRequest.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 |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| package com.example.demo.controller.dto.request; | ||
|
|
||
| import jakarta.annotation.Nonnull; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record ArticleCreateRequest( | ||
| Long authorId, | ||
| Long boardId, | ||
| String title, | ||
| String description | ||
| @NotNull(message = "멤버ID를 입력해주세요.") Long authorId, | ||
| @NotNull(message = "게시판ID를 입력해주세요.") Long boardId, | ||
| @NotNull(message = "제목을 입력해주세요.") String title, | ||
| @NotNull(message = "내용을 입력해주세요.") String content | ||
| ) { | ||
|
|
||
| } | ||
4 changes: 3 additions & 1 deletion
4
src/main/java/com/example/demo/controller/dto/request/BoardCreateRequest.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 |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| package com.example.demo.controller.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record BoardCreateRequest( | ||
| String name | ||
| @NotNull(message = "이름을 입력해주세요.") String name | ||
| ) { | ||
|
|
||
| } |
8 changes: 5 additions & 3 deletions
8
src/main/java/com/example/demo/controller/dto/request/MemberCreateRequest.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 |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| package com.example.demo.controller.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record MemberCreateRequest( | ||
| String name, | ||
| String email, | ||
| String password | ||
| @NotNull(message = "이름을 입력해주세요.") String name, | ||
| @NotNull(message = "이메일을 입력해주세요.") String email, | ||
| @NotNull(message = "비밀번호를 입력해주세요") String password | ||
| ) { | ||
|
|
||
| } |
6 changes: 4 additions & 2 deletions
6
src/main/java/com/example/demo/controller/dto/request/MemberUpdateRequest.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 |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| package com.example.demo.controller.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record MemberUpdateRequest( | ||
| String name, | ||
| String email | ||
| @NotNull(message = "멤버의 이름을 적어주세요.") String name, | ||
| @NotNull(message = "멤버의 이메일을 적어주세요") String email | ||
| ) { | ||
|
|
||
| } |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/example/demo/exception/errorcode/CommonErrorCode.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,25 @@ | ||
| package com.example.demo.exception.errorcode; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum CommonErrorCode implements ErrorCode { | ||
| EMAIL_ALREADY_EXIST(HttpStatus.CONFLICT, "이미 존재하는 이메일입니다."), | ||
| GET_ARTICLE_NOT_EXIST(HttpStatus.NOT_FOUND, "입력한 ID에 해당하는 게시물이 존재하지 않습니다."), | ||
| GET_MEMBER_NOT_EXIST(HttpStatus.NOT_FOUND, "입력한 ID에 해당하는 멤버가 존재하지 않습니다."), | ||
| GET_BOARD_NOT_EXIST(HttpStatus.NOT_FOUND, "입력한 ID에 해당하는 게시판이 존재하지 않습니다."), | ||
| POST_ARTICLE_NOT_EXIST(HttpStatus.BAD_REQUEST, "입력한 ID에 해당하는 게시물이 존재하지 않습니다."), | ||
| POST_MEMBER_NOT_EXIST(HttpStatus.BAD_REQUEST, "입력한 ID에 해당하는 멤버가 존재하지 않습니다."), | ||
| POST_BOARD_NOT_EXIST(HttpStatus.BAD_REQUEST, "입력한 ID에 해당하는 게시판이 존재하지 않습니다."), | ||
| UPDATE_BOARD_NOT_EXIST(HttpStatus.BAD_REQUEST,"입력한 ID에 해당하는 게시판이 존재하지 않습니다." ), | ||
|
Comment on lines
+16
to
+17
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. 동일한 상태코드와 반환 메세지라면 하나 통일해서 써도 될 것 같아요 |
||
| UPDATE_NAME_NULL(HttpStatus.BAD_REQUEST, "변경할 이름을 입력해주세요"), | ||
| UPDATE_EMAIL_NULL(HttpStatus.BAD_REQUEST, "변경할 이메일을 입력해주세요"), | ||
| DELETE_ARTICLE_EXIST_IN_MEMBER(HttpStatus.BAD_REQUEST, "해당 멤버가 작성한 게시물이 존재합니다."), | ||
| DELETE_ARTICLE_EXIST_IN_BOARD(HttpStatus.BAD_REQUEST, "해당 게시판에 게시물이 존재합니다."); | ||
|
|
||
| private final HttpStatus httpStatus; | ||
| private final String message; | ||
| } | ||
9 changes: 9 additions & 0 deletions
9
src/main/java/com/example/demo/exception/errorcode/ErrorCode.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,9 @@ | ||
| package com.example.demo.exception.errorcode; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| public interface ErrorCode { | ||
| String name(); | ||
| HttpStatus getHttpStatus(); | ||
| String getMessage(); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/example/demo/exception/exception/RestApiException.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,11 @@ | ||
| package com.example.demo.exception.exception; | ||
|
|
||
| import com.example.demo.exception.errorcode.ErrorCode; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public class RestApiException extends RuntimeException{ | ||
| private final ErrorCode errorCode; | ||
| } |
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.
@NotNull 어노테이션 잘 사용하셨네요!