Skip to content

Commit

Permalink
fix: 그룹 정보 응답
Browse files Browse the repository at this point in the history
  • Loading branch information
SangWoon123 committed Aug 31, 2024
1 parent 55f1b76 commit c2039d2
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@Builder
public record GroupInformationResponse(
Long id,
String owner,
String name,
String groupCode,
String description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public GroupInformationResponse getGroupUsers(UserInfo userInfo, String groupCod

return GroupInformationResponse.builder()
.id(groupRoom.getId())
.owner(groupRoom.getOwner())
.users(userInfoSimples)
.groupCode(groupRoom.getGroupCode())
.name(groupRoom.getName())
Expand Down
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();
}
}
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);
}
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();
}
}

0 comments on commit c2039d2

Please sign in to comment.