-
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
base: main
Are you sure you want to change the base?
Conversation
duehee
left a comment
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.
수고하셨습니다~
| private final Long authorId; | ||
| private Long boardId; | ||
| private String title; | ||
| private String content; | ||
| private LocalDateTime createdAt; | ||
| private final LocalDateTime createdAt; |
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.
author Id와 createdAt에만 final을 선언한 이유가 있나요?
| POST_BOARD_NOT_EXIST(HttpStatus.BAD_REQUEST, "입력한 ID에 해당하는 게시판이 존재하지 않습니다."), | ||
| UPDATE_BOARD_NOT_EXIST(HttpStatus.BAD_REQUEST,"입력한 ID에 해당하는 게시판이 존재하지 않습니다." ), |
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.
동일한 상태코드와 반환 메세지라면 하나 통일해서 써도 될 것 같아요
| try { | ||
| member = memberRepository.findById(saved.getAuthorId()); | ||
| } catch(RuntimeException e) { | ||
| throw new RestApiException(CommonErrorCode.POST_MEMBER_NOT_EXIST); | ||
| } | ||
| try { | ||
| board = boardRepository.findById(saved.getBoardId()); | ||
| } catch(RuntimeException e) { | ||
| throw new RestApiException(CommonErrorCode.POST_BOARD_NOT_EXIST); | ||
| } |
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.
Ctrl + Alt + L 이용하면 라인 포맷팅이 된답니다
한 번씩 눌러주세요~
| private final String field; | ||
| private final String message; | ||
|
|
||
| public static ValidationError of(final FieldError fieldError) { |
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.
매개변수를 하나 받는 경우에는 of보단 from을 더 사용해요
참고 블로그
| url: jdbc:mysql://localhost:3306/bcsd # 본인의 환경에 맞게 수정한다. | ||
| username: root # 본인의 환경에 맞게 수정한다. | ||
| password: qwer1234 # 본인의 환경에 맞게 수정한다. | ||
| password: "6235" # 본인의 환경에 맞게 수정한다. |
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.
.gitignore를 사용해보세요!
| String description | ||
| @NotNull(message = "멤버ID를 입력해주세요.") Long authorId, | ||
| @NotNull(message = "게시판ID를 입력해주세요.") Long boardId, | ||
| @NotNull(message = "제목을 입력해주세요.") String title, |
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 어노테이션 잘 사용하셨네요!
MemberRepositoryJpa 추가, Member에 @entity 어노테이션 추가
BoardRepositoryJpa추가 + Board도메인에 @entity 추가
ArticleRepositoryJpa 추가, Article도메인에 @entity 추가
SpringDataJpa형식으로 변경 (extends JpaRepository<Board, Long>
SpringDataJpa형식으로 변경 (extends JpaRepository<Member, Long>
SpringDataJpa형식으로 변경 (extends JpaRepository<Article, Long>
AOP에 관해 공부해 볼 좋은 기회였습니다