-
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: 검색 #28
feat: 검색 #28
Conversation
fragrance.thumbnail, | ||
fragrance.name.as("fragranceName"), | ||
fragrance.brand.korName | ||
)).distinct() |
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.
오 저는 selectDistinct()로 했는데 따로 해도 되는군요!
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.
selectDistinct()
로 해도 되는군용!!😆😆
|
||
|
||
@Override | ||
public Page<BrandInfo> searchBrand(String search, 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.
검색하는 String이 korName or engName에 포함되는 건지 조회하는 거라면 List findByKorNameContainingIgnoreCaseOrEngNameContainingIgnoreCase(String korName, String engName); 으로는 안될까요?🤔
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.
영어 이름과 한글 이름을 한 번에 확인하는 메소드로 빼는 것은 좋은 방법같아요!
하지만 너무 긴 이름은 오히려 좋지 않을 것 같아서 brandNameContains()
정도가 적당할 것 같네욤
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에서 조회하는 방법을 말하셨던 걸까욥?!
JpaRepository의 메소드 이름 규칙을 통해 메소드 이름만 지으면 JpaRepository가 알아서 쿼리를 짜주는 방법은
반환 타입이 해당 리포지토리의 타입(엔티티)일 경우에만 적용되는 것 같고
JpaRepository에서 DTO로 조회하려면
@Query(
"SELECT new server.acode.domain.fragrance.dto.response.BrandInfo(b.brand_id, b.kor_name, b.round_img) " +
" FROM Brand b " +
"WHERE b.kor_name = :search OR b.eng_name = :search")
Page<BrandInfo> searchBrand(@Param("search") String search, Pageable pageable);
이런 식으로 DTO의 경로를 적어주어야 한다고 하네용
사실 그냥 쿼리dsl을 사용했는데
찾아보고 나니 쿼리dsl을 사용하길 잘한 것 같다는 생각이 드네욥..! 😂😂
PR
PR 요약
변경된 점
이슈 번호