Skip to content

박시현 API 구축코드#5

Open
avocado-13 wants to merge 2 commits intoGDSC-PKNU-Official:mainfrom
avocado-13:main
Open

박시현 API 구축코드#5
avocado-13 wants to merge 2 commits intoGDSC-PKNU-Official:mainfrom
avocado-13:main

Conversation

@avocado-13
Copy link
Copy Markdown

TaskController는 할 일의 생성, 조회, 삭제를 담당합니다.
UserController는 사용자의 생성과 조회를 담당합니다.

Copy link
Copy Markdown
Contributor

@coke98 coke98 left a comment

Choose a reason for hiding this comment

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

LGTM! 데이터베이스도 이번에 연동해서 작성해주셨네요~! 추후 제대로 사용하기 위해서는 ORM 원리를 조금 더 심화적으로 다뤄봐도 좋을 것 같아요. 고생하셨습니다~!

private boolean completed;

// 기본 생성자
public Task() {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

별도로 기본 생성자가 있어야하는 이유는 과연 무엇일까요?👀 답변으로 달아주세요!

import org.springframework.stereotype.Repository;

@Repository
public interface TaskRepository extends JpaRepository<Task, Long> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

jpa와 h2 데이터베이스를 사용하셨네요~!👍
jpa에서 Repository 어노테이션은 어떤 역할들을 수행하고 있을까요?

public class TaskController {

@Autowired
private TaskRepository taskRepository;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

필드에 바로 @Autowired 어노테이션만 쓰는 것 보다, 생성자를 통한 주입 방식을 쓰는 편을 더 권장하곤 합니다. 어떤 이유인지 확인 후 답변으로 남겨주시면 다른 분들도 참고할 수 있을 것 같아요

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants