-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: GymRepository에 querydsl 적용 (#274) * refactor: List를 반환하도록 변경 (#274) * test: test 코드 추가 (#274) * style: 변수명 변경 (#274) * style: 변수명 변경 (#274) * test: test 로직 변경 (#277) * fix: 정규 표현식 변경 (#274)
- Loading branch information
1 parent
d443b67
commit 23b0f4a
Showing
5 changed files
with
73 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/newfit/reservation/domains/gym/repository/GymRepositoryCustom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.newfit.reservation.domains.gym.repository; | ||
|
||
import com.newfit.reservation.domains.gym.domain.Gym; | ||
import java.util.List; | ||
|
||
public interface GymRepositoryCustom { | ||
|
||
List<Gym> findAllByNameContaining(List<String> keywordString); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/newfit/reservation/domains/gym/repository/GymRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.newfit.reservation.domains.gym.repository; | ||
|
||
import com.newfit.reservation.domains.gym.domain.Gym; | ||
import com.querydsl.core.BooleanBuilder; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import java.util.List; | ||
|
||
import static com.newfit.reservation.domains.gym.domain.QGym.*; | ||
|
||
@RequiredArgsConstructor | ||
public class GymRepositoryImpl implements GymRepositoryCustom { | ||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Gym> findAllByNameContaining(List<String> keywords) { | ||
return queryFactory | ||
.selectFrom(gym) | ||
.where(containsKeyword(keywords)) | ||
.fetch(); | ||
} | ||
|
||
private BooleanBuilder containsKeyword(List<String> keywords) { | ||
return keywords.stream() | ||
.map(keyword -> gym.name.toLowerCase().contains(keyword.toLowerCase())) | ||
.reduce(new BooleanBuilder(), BooleanBuilder::or, BooleanBuilder::or); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters