Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,25 @@ public ContestRepositoryImpl(EntityManager em) {

@Override
public Page<Contest> searchList(String word, String sortAt, Pageable pageable) {
BooleanExpression filterCondition = wordEq(word);

if ("ACTIVE".equals(sortAt)) {
filterCondition = (filterCondition == null ? contest.finishedAt.goe(LocalDate.now())
: filterCondition.and(contest.finishedAt.goe(LocalDate.now())));
}

List<Contest> contestList = queryFactory
.selectDistinct(contest)
.from(contest)
.where(wordEq(word))
.where(filterCondition)
.orderBy(arg(sortAt))
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
long total = queryFactory
.select(contest.count())
.from(contest)
.where(wordEq(word)) // Full-Text Search 조건 추가
.where(filterCondition) // Full-Text Search 조건 추가
.fetchOne();

return new PageImpl<>(contestList,pageable,total);
Expand All @@ -45,8 +52,8 @@ private OrderSpecifier<?> arg(String sortAt){
if("VIEW".equals(sortAt)){
return contest.view.desc();//조회순
}
if("ACTIVE".equals(sortAt)){
return contest.finishedAt.after(LocalDate.now()).desc(); //활동 중인 공모전
if ("ACTIVE".equals(sortAt)) {
return contest.finishedAt.asc(); // 종료일 기준 오름차순
}
return contest.createdAt.desc(); //최신순
}
Expand Down