-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨ save categories of recipe #68
Conversation
- add method to find category by name
|
public class Category { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private long id; | ||
|
||
private String name; | ||
|
||
public Category(String name) { | ||
this(0, name); |
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.
여러분 일관성을 위해 앞으로 둘중 하나로 통일하는건 어떤가요??
this(0, name);
this(0L, name);
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.
토의 결과대로 0L로 변경하도록 하겠습니다~
|
||
@Entity | ||
@NoArgsConstructor |
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.
@NoArgsConstructor
에 접근 지정자를 붙여줘도 좋을것 같아요
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.
그런 기능이 있었군요
좋은 생각입니다
추가하겠습니다~
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.
테스트 커버리지도 좋고 전체적으로 코드가 짜임새 있게 작성된 것 같았습니다! 굿굿~
|
||
@DataJpaTest | ||
@Import(CategoryService.class) | ||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) |
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.
혹시 이 부분(23 line)은 무슨 의도 일까용?!
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.
로키 테스트에서 긁어서 변경 후 사용했는데 저한테는 필요 없는 부분이 딸려왔네요
인메모리 db로도 충분한 테스트인 것 같습니다!
|
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.
전체적으로 깔끔하네요. 궁금한부분 하나만 코멘트 남겨두었습니다. 고생많으셨어요!
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository |
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.
JpaRepository를 상속받고있어서 애너테이션을 제거해도 정상동작할것같은데요, 넣어두신 이유가 궁금합니다!
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.
JpaRepository면 Spring Data JPA가 알아서 구현체를 주입해주는군요!
처음 알았네요.
빈으로 등록이 안될 것이라 생각하고 붙였습니다.
수정하겠습니다~
|
|
|
카테고리명을 List로 받아 각각의 String에 대해 저장 작업을 합니다.
카테고리 하나의 저장 과정은 다음과 같습니다.
먼저 그 String이 카테고리 테이블에 있는지 확인합니다.
있다면 그 카테고리를 가져오고, 없다면 String을 카테고리 테이블에 저장한 후 가져옵니다.
그리고 레시피-카테고리 중간 테이블에 저장합니다.