Skip to content
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

refactor : query->querydsl로 수정 #243

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
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 @@ -6,5 +6,12 @@
import org.springframework.data.domain.Pageable;

public interface ContestRepositoryCustom {
/**
* 찾고자하는 단어 검색
* @param word searchWord
* @param sort 정렬순
*/
Page<Contest> searchList (String word, String sort, Pageable pageable);


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public ContestRepositoryImpl(EntityManager em) {
this.queryFactory = new JPAQueryFactory(em);
}

//최신순으로 정렬
//제목,본문 기준으로 검색
@Override
public Page<Contest> searchList(String word, String sortAt, Pageable pageable) {
List<Contest> contestList = queryFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@
public interface PortfolioRepository extends JpaRepository<Portfolio, Long>, PortfolioRepositoryCustom{
Optional<Portfolio> findByIdAndDeletedAtIsNull(Long portfolioId);
long countByDeletedAtIsNull();
@Query("SELECT EXISTS (" +
"SELECT 1 FROM Portfolio po " +
"WHERE po.member = :member AND (po.fileUri IS NOT NULL OR po.notionUri IS NOT NULL) AND po.deletedAt IS NULL )")
Boolean existsExistPortfolioByMember(@Param("member") Member member);
Optional<Portfolio> findPortfolioById(Long portfolioId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

public interface PortfolioRepositoryCustom {
List<Portfolio> findByMemberAndDeletedAtIsNull(Member member);
Boolean existsExistPortfolioByMember(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ public List<Portfolio> findByMemberAndDeletedAtIsNull(Member member) {
.and(portfolio.deletedAt.isNull()))
.fetch();
}

public Boolean existsExistPortfolioByMember(Member member){
return queryFactory
.selectFrom(portfolio)
.where(portfolio.member.eq(member)
.and(portfolio.fileUri.isNotNull().or(portfolio.notionUri.isNotNull()))
.and(portfolio.deletedAt.isNull()))
.fetchFirst()!=null;
}
}
Loading