Skip to content
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 게시판 구현 미션 제출합니다. #271

Open
wants to merge 10 commits into
base: JIN-076-happyjamy
Choose a base branch
from

Conversation

JIN-076
Copy link

@JIN-076 JIN-076 commented Nov 23, 2023

📌 과제 설명

Spring Data JPA를 사용한 게시판 구현

👩‍💻 요구 사항과 구현 내용

SpringDataJPA 설정

  • datasource : h2 database

엔티티 구성

  • 회원 (user)
    • id (PK) (auto increment)
    • name
    • age
    • hobby
    • created_at
    • created_by
  • 게시글 (post)
    • id (PK) (auto increment)
    • title
    • content
    • created_at
    • created_by
  • 회원과 게시글에 대한 연관 관계를 설정한다.
    • 회원과 게시글은 1 : N 관계이다.
  • 게시글 Repository를 구현한다.

API 구현

  • 게시글 작성 (POST "/posts")
  • 게시글 조회
    • 페이징 조회 (GET "/posts")
    • 단건 조회 (GET "/posts/{id}")
  • 게시글 수정 (POST "/posts/{id}")
  • REST-DOCS를 이용해서 문서화한다.

✅ PR 포인트 & 궁금한 점

Copy link

@SeokRae SeokRae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요. 주환님, 지인님 멘토 알입니다.

JPA Board는 어떤 내용을 학습하는 단계인 걸까요?
구현하신 내용들을 보아하니 JPA가 들어가면서 테이블 설계와 쿼리, RestDocs 등이 새롭게 추가된 것 처럼보이는데, JPA 관련 테스트는 보이지 않는 것 같습니다.

쿼리가 날아가는 부분에 대해서도 테스트가 추가되면 좋겠네요.


@Configuration
@EnableJpaAuditing
public class JpaConfig {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 점차 서비스에 여러 설정들이 필요한 경우 관련 Configuration 클래스들을 각각 관리하는 것도 좋은 방법입니다.


private final PostService postService;

@GetMapping("")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 ""를 꼭 붙여야하는 이유가 있을까요!?

import org.programmers.dev.domain.post.domain.entity.Post;

@NoArgsConstructor
@Data
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaTa 어노테이션은 어떤 어노테이션을 포함하고 있을까요?
최소한의 어노테이션만 사용하는 것을 권장합니다.

PostValidationException.class,
PostNotFoundException.class
})
public ResponseEntity<ErrorResponse> handle400Exception(Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public ResponseEntity<ErrorResponse> handle400Exception(Exception e) {
public ResponseEntity<ErrorResponse> handle400Exception(RuntimeException e) {

ExceptionHandler에 선언된 예외들이 RuntimeException 예외를 상속받아 사용되어 인자 값으로 RuntimeException을 사용하는 것이 좋겠네요.!

@@ -0,0 +1 @@

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yml 파일로 관리하는 거라면 properties 파일은 지워도 되겠네요.!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants