-
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
feat: product tag 생성 #72
base: week7
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.
혹시 product tag는 그냥 product에 tag를 enum으로 두도록 하는건 어떤지 싶습니다!!! 이것까지 Entity로 관리하면 조금 오버 엔지니어링 같은 느낌이 드네요😢
@stopmin enum으로 관리하게 바꿔봤습니다 |
@@ -64,6 +70,12 @@ public class Product { | |||
@JoinColumn(name = "entityId") | |||
List<Review> reviewList = new ArrayList<>(); | |||
|
|||
@ElementCollection(fetch = FetchType.EAGER) |
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.
혹시 Lazy대신 Eager로 설정하신 이유가 궁금합니다!!!
@@ -4,7 +4,7 @@ | |||
|
|||
public record ReviewResponse | |||
(Long id, | |||
Long productId, | |||
Long entityId, |
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.
product, farm 둘다 쓸 ㅇ예정이라 Entity로 네이밍을 수정하신건지 궁금합니다!
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.
저는 product랑 farm이랑 id값이 중복될 수 있으니 따로 type을 받아야겠다 생각했는데
ReviewRepository에서
@query("select r from Review r where r.entityId = :productId and r.entityType = 'PRODUCT'")
와 같은 쿼리문 써서 type 받을 필요도 없도록 잘 구현해주셨네요 하나 배웠습니다~!
다만 리뷰를 가지는 엔티티가 많을 경우에는 type을 받으면 하나의 로직으로 공통화하기 좋을 것 같기는 하네여
|
||
public enum ProductTagEnum { | ||
ORGANIC("유기농"), | ||
NonPesticide("무농약"); |
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.
enum이니깐
NON_PESTICIDE("무농약"); 으로 쓰는 것은 어떨까요?
} | ||
|
||
private Product CheckProduct(ProductTagRequest productTagRequest) { | ||
return productRepository.findById(productTagRequest.productId()) |
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.
findByIdAndDeletedAtIsNull로 바꾸는 것은 어떨까요?
혹시 제가 틀린 거라면 바로 피드백 주시면 감사하겠습니당
Product product = CheckProduct(productTagRequest); | ||
|
||
ProductTagEnum productTagEnum = null; | ||
try { |
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.
이 부분은 addTag에 있는 로직과 동일해서 공통화시키면 좋을 것 같다는 생각이 듭니당
@@ -4,7 +4,7 @@ | |||
|
|||
public record ReviewResponse | |||
(Long id, | |||
Long productId, | |||
Long entityId, |
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.
저는 product랑 farm이랑 id값이 중복될 수 있으니 따로 type을 받아야겠다 생각했는데
ReviewRepository에서
@query("select r from Review r where r.entityId = :productId and r.entityType = 'PRODUCT'")
와 같은 쿼리문 써서 type 받을 필요도 없도록 잘 구현해주셨네요 하나 배웠습니다~!
다만 리뷰를 가지는 엔티티가 많을 경우에는 type을 받으면 하나의 로직으로 공통화하기 좋을 것 같기는 하네여
해결하려는 문제가 무엇인가요?
어떻게 해결했나요?
코드 리뷰시 요청 사항
더 하고 싶은 말