-
Notifications
You must be signed in to change notification settings - Fork 203
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
[5기 김남규, 박유진] Spring Boot JPA 게시판 구현 미션 제출합니다. #269
base: eugene_namgyu
Are you sure you want to change the base?
Conversation
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.
구현하고 반영해주시느라 고생많으셨어요.
따로 코멘트가 없어서 완료된걸로 이해했어요. 다음부터는 완료되면 따로 코멘트 남겨주시면 좋을 것 같아요.
리뷰 남겨놓은 부분은 고민해보시고 남겨주시면 좋을 것 같고 머지해주셔도 좋습니다 👍
@@ -38,8 +38,7 @@ public ApiResponse<PostDto> create(@RequestBody PostRequestDto postRequestDto, @ | |||
} // body에서 전부 받는 방식으로 | |||
|
|||
//수정 | |||
// post, put, patch ... HTTP 메서드 - 멱등성 | |||
@PostMapping("/{id}") | |||
@PutMapping("/{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.
👍
private void validateNull(String input) { | ||
if(input.isEmpty() || input.isBlank()) throw new NullPointerException("NPE"); |
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.
검증좋네요 👍
나중에 title / content에서 길이와 같은 개별 검증이 들어갈 수 있을 것 같기도 해서 각각 분리해보는걸 고려해봐도 좋을 것 같아요 👍
|
||
@RestControllerAdvice | ||
@RestControllerAdvice(basePackageClasses = PostController.class) |
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.
패키지는 공통 exception이지만 포스트 컨트롤러에 대해서만 적용하신 이유가 있나요?
public ApiResponse<String> notFoundHandler(ChangeSetPersister.NotFoundException e) { | ||
return ApiResponse.fail(NOT_FOUND, e.getMessage()); | ||
public ResponseEntity<String> notFoundHandler(ChangeSetPersister.NotFoundException e) { | ||
return ResponseEntity.status(NOT_FOUND).body(e.getMessage()); |
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.
HttpStatusCode를 활용하는걸 고려해보세요.
return ApiResponse.fail(INTERNAL_SERVER_ERROR, e.getMessage()); | ||
} // 다음 타자 ................. | ||
public ResponseEntity<String> internalServerErrorHandler(Exception e) { | ||
return ResponseEntity.status(INTERNAL_SERVER_ERROR).body(e.getMessage()); |
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.
HttpStatusCode를 활용하는걸 고려해보세요.
private void validateAge(int age) { | ||
if(age <= 0 || age >= 200) throw new NullPointerException("NPE"); | ||
if(age <= 0 || age >= 200) throw new IllegalArgumentException("나이는 1~199세 사이의 값 이어야 합니다."); |
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.
관련 검증을 Age 자체에 넘길 수 있도록 값객체로 선언할 수 있을 것 같아요.
나중에 고민해보시면 좋을 것 같아요 👍
|
||
//페이지 조회 -> get | ||
@GetMapping | ||
public ResponseEntity<Page<PostDto>> getAll(Pageable pageable) { |
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.
pageable로 받는 부분을 수정해보면 좋을 것 같네요 👍
import com.prgrms.dev.springbootboardjpa.dto.UserDto; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component |
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.
꼭 빈으로 등록되어야할까요?
📌 과제 설명
Spring Boot JPA - Rest API를 강의를 듣고, 게시판 구현 미션 수행
👩💻 요구 사항과 구현 내용
SpringDataJPA 를 설정한다.
엔티티를 구성한다
회원(User)
게시글(Post)
회원과 게시글에 대한 연관관계를 설정한다.
게시글 Repository를 구현한다. (PostRepository)
API를 구현한다.
문서화
✅ 피드백 반영사항
@AllArgsConstructor
→@RequiredConstructor
수정@JsonFormat
@DateTimeFormat
포맷 사용 구분✅ PR 포인트 & 궁금한 점
GeneratedValue 전략 : Sequence vs Identity
CascadeType.ALL
+orphanRemoval=true
Entity생성 시 기본 생성자를 필요로 하는 이유
궁금한 점