-
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.
Merge pull request #59 from WE-ARE-RACCOONS/RAC-155
RAC-155 feat : λ©ν κ²μ κΈ°λ₯ ꡬν
- Loading branch information
Showing
15 changed files
with
189 additions
and
25 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
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
7 changes: 7 additions & 0 deletions
7
...main/java/com/postgraduate/domain/senior/application/dto/res/AllSeniorSearchResponse.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,7 @@ | ||
package com.postgraduate.domain.senior.application.dto.res; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public record AllSeniorSearchResponse(@NotNull List<SeniorSearchResponse> seniorSearchResponses) {} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/postgraduate/domain/senior/application/dto/res/SeniorSearchResponse.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,20 @@ | ||
package com.postgraduate.domain.senior.application.dto.res; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record SeniorSearchResponse( | ||
@NotNull | ||
String profile, | ||
@NotNull | ||
String nickName, | ||
@NotNull | ||
String postgradu, | ||
@NotNull | ||
String major, | ||
@NotNull | ||
String lab, | ||
@NotNull | ||
String oneLiner, | ||
@NotNull | ||
String[] keyword | ||
) {} |
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
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
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/postgraduate/domain/senior/domain/repository/SeniorDslRepository.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.postgraduate.domain.senior.domain.repository; | ||
|
||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface SeniorDslRepository { | ||
Page<Senior> findAllSenior(String search, String sort, Pageable pageable); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.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,51 @@ | ||
package com.postgraduate.domain.senior.domain.repository; | ||
|
||
import com.postgraduate.domain.senior.domain.entity.Senior; | ||
import com.querydsl.core.types.Order; | ||
import com.querydsl.core.types.OrderSpecifier; | ||
import com.querydsl.jpa.impl.JPAQuery; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
import static com.postgraduate.domain.senior.domain.entity.QSenior.senior; | ||
import static com.postgraduate.domain.senior.domain.entity.constant.Status.APPROVE; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class SeniorDslRepositoryImpl implements SeniorDslRepository{ | ||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public Page<Senior> findAllSenior(String search, String sort, Pageable pageable) { | ||
JPAQuery<Senior> query = queryFactory.selectFrom(senior) | ||
.where( | ||
senior.info.totalInfo.like("%" + search + "%"), | ||
senior.status.eq(APPROVE) | ||
) | ||
.orderBy(orderSpecifier(sort)); | ||
|
||
List<Senior> seniors = query.offset(pageable.getOffset()) | ||
.limit(pageable.getPageSize()) | ||
.fetch(); | ||
|
||
long total = query.fetchCount(); | ||
|
||
return new PageImpl<>(seniors, pageable, total); | ||
} | ||
|
||
private OrderSpecifier<?> orderSpecifier(String sort) { | ||
if (sort == null) | ||
return new OrderSpecifier<>(Order.DESC, senior.hit); | ||
return switch (sort) { | ||
case "low" -> new OrderSpecifier<>(Order.ASC, senior.hit); | ||
default -> new OrderSpecifier<>(Order.DESC, senior.hit); | ||
}; | ||
} | ||
|
||
} |
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
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