-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
10 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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/sponus/sponusbe/domain/propose/repository/ProposeCustomRepository.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,12 @@ | ||
package com.sponus.sponusbe.domain.propose.repository; | ||
|
||
import java.util.List; | ||
|
||
import com.sponus.sponusbe.domain.propose.entity.Propose; | ||
|
||
public interface ProposeCustomRepository { | ||
|
||
List<Propose> findSentPropose(Long id); | ||
|
||
List<Propose> findReceivedProposeWithAnnouncementId(Long organizationId, Long announcementId); | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/sponus/sponusbe/domain/propose/repository/ProposeCustomRepositoryImpl.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,46 @@ | ||
package com.sponus.sponusbe.domain.propose.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.sponus.sponusbe.domain.propose.entity.Propose; | ||
import com.sponus.sponusbe.domain.propose.entity.QPropose; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class ProposeCustomRepositoryImpl implements ProposeCustomRepository { | ||
|
||
private final EntityManager entityManager; | ||
|
||
@Override | ||
|
||
public List<Propose> findSentPropose(Long id) { | ||
QPropose p = QPropose.propose; | ||
|
||
JPAQueryFactory queryFactory = new JPAQueryFactory(entityManager); | ||
|
||
return queryFactory.selectFrom(p) | ||
.where(p.proposingOrganization.id.eq(id)) | ||
.leftJoin(p.proposingOrganization).fetchJoin() | ||
.fetch(); | ||
} | ||
|
||
@Override | ||
public List<Propose> findReceivedProposeWithAnnouncementId(Long organizationId, Long announcementId) { | ||
QPropose p = QPropose.propose; | ||
|
||
JPAQueryFactory queryFactory = new JPAQueryFactory(entityManager); | ||
|
||
return queryFactory.selectFrom(p) | ||
.where(p.proposedOrganization.id.eq(organizationId) | ||
.and(p.announcement.id.eq(announcementId))) | ||
.leftJoin(p.proposedOrganization).fetchJoin() | ||
.leftJoin(p.announcement) | ||
.fetch(); | ||
} | ||
} |
13 changes: 5 additions & 8 deletions
13
src/main/java/com/sponus/sponusbe/domain/propose/repository/ProposeRepository.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 |
---|---|---|
@@ -1,17 +1,14 @@ | ||
package com.sponus.sponusbe.domain.propose.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import com.sponus.sponusbe.domain.propose.entity.Propose; | ||
|
||
public interface ProposeRepository extends JpaRepository<Propose, Long> { | ||
@Query("SELECT p FROM Propose p WHERE p.proposingOrganization.id = :id") | ||
List<Propose> findSentPropose(Long id); | ||
|
||
@Query("SELECT p FROM Propose p WHERE p.proposedOrganization.id = :organizationId AND p.announcement.id = :announcementId") | ||
List<Propose> findReceivedProposeWithAnnouncementId(Long organizationId, Long announcementId); | ||
// @Query("SELECT p FROM Propose p WHERE p.proposingOrganization.id = :id") | ||
// List<Propose> findSentPropose(Long id); | ||
// | ||
// @Query("SELECT p FROM Propose p WHERE p.proposedOrganization.id = :organizationId AND p.announcement.id = :announcementId") | ||
// List<Propose> findReceivedProposeWithAnnouncementId(Long organizationId, Long announcementId); | ||
|
||
} |
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