-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartnershipRepository.java
More file actions
32 lines (28 loc) · 1.29 KB
/
PartnershipRepository.java
File metadata and controls
32 lines (28 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ssu.eatssu.domain.partnership.persistence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import ssu.eatssu.domain.partnership.entity.Partnership;
import ssu.eatssu.domain.partnership.entity.PartnershipRestaurant;
import ssu.eatssu.domain.user.department.entity.College;
import ssu.eatssu.domain.user.department.entity.Department;
import java.util.List;
public interface PartnershipRepository extends JpaRepository<Partnership, Long> {
@Query("""
select distinct pr
from PartnershipRestaurant pr
join fetch pr.partnerships p
left join fetch p.partnershipCollege pc
left join fetch p.partnershipDepartment pd
where
(pc = :college
or pd = :department
or (pc is not null and pc.name = '총학'))
and p.startDate <= current_date
and (p.endDate is null or p.endDate >= current_date)
""")
List<PartnershipRestaurant> findRestaurantsWithMyPartnerships(
@Param("college") College college,
@Param("department") Department department
);
}