-
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.
- Loading branch information
1 parent
55f1b76
commit c2039d2
Showing
5 changed files
with
85 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/tukorea/planding/domain/planner/dto/SchedulePlannerResponse.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,31 @@ | ||
package com.tukorea.planding.domain.planner.dto; | ||
|
||
import com.tukorea.planding.domain.notify.entity.NotificationType; | ||
import com.tukorea.planding.domain.planner.entity.Planner; | ||
import com.tukorea.planding.domain.schedule.entity.Schedule; | ||
import com.tukorea.planding.domain.schedule.entity.ScheduleType; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Builder | ||
public record SchedulePlannerResponse( | ||
List<PlannerResponse> planners, | ||
Long scheduleId, | ||
NotificationType type, | ||
ScheduleType scheduleType | ||
) { | ||
public static SchedulePlannerResponse fromEntity(List<Planner> planners, Schedule schedule) { | ||
List<PlannerResponse> plannerResponses = planners.stream() | ||
.map(PlannerResponse::fromEntity) | ||
.collect(Collectors.toList()); | ||
|
||
return SchedulePlannerResponse.builder() | ||
.planners(plannerResponses) | ||
.scheduleId(schedule.getId()) | ||
.type(NotificationType.PLANNER) | ||
.scheduleType(schedule.getType()) | ||
.build(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/tukorea/planding/domain/planner/repository/PlannerRepositoryCustom.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,10 @@ | ||
package com.tukorea.planding.domain.planner.repository; | ||
|
||
import com.tukorea.planding.domain.planner.entity.Planner; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public interface PlannerRepositoryCustom { | ||
List<Planner> findPlannersByGroupCodeAndDateRange(String groupCode, LocalDate startDate, LocalDate endDate); | ||
} |
42 changes: 42 additions & 0 deletions
42
...main/java/com/tukorea/planding/domain/planner/repository/PlannerRepositoryCustomImpl.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,42 @@ | ||
package com.tukorea.planding.domain.planner.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import com.tukorea.planding.domain.group.entity.QGroupRoom; | ||
import com.tukorea.planding.domain.planner.entity.Planner; | ||
import com.tukorea.planding.domain.schedule.entity.QGroupSchedule; | ||
import com.tukorea.planding.domain.schedule.entity.QSchedule; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import static com.tukorea.planding.domain.group.entity.QGroupRoom.groupRoom; | ||
import static com.tukorea.planding.domain.planner.entity.QPlanner.planner; | ||
import static com.tukorea.planding.domain.schedule.entity.QGroupSchedule.groupSchedule; | ||
import static com.tukorea.planding.domain.schedule.entity.QSchedule.schedule; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class PlannerRepositoryCustomImpl implements PlannerRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Planner> findPlannersByGroupCodeAndDateRange(String groupCode, LocalDate startDate, LocalDate endDate) { | ||
QSchedule schedule = QSchedule.schedule; | ||
QGroupSchedule groupSchedule = QGroupSchedule.groupSchedule; | ||
QGroupRoom groupRoom = QGroupRoom.groupRoom; | ||
|
||
return queryFactory.selectFrom(planner) | ||
.join(planner.schedule, schedule) | ||
.join(schedule.groupSchedule, groupSchedule) | ||
.join(groupSchedule.groupRoom, groupRoom) | ||
.where( | ||
groupRoom.groupCode.eq(groupCode) | ||
.and(schedule.scheduleDate.between(startDate, endDate)) | ||
) | ||
.groupBy(schedule.id, schedule.scheduleDate, schedule.title) // GROUP BY에 모든 비집계 열 추가 | ||
.fetch(); | ||
} | ||
} |