diff --git a/src/main/java/net/teumteum/meeting/controller/MeetingController.java b/src/main/java/net/teumteum/meeting/controller/MeetingController.java index 39afff4e..df4e9149 100644 --- a/src/main/java/net/teumteum/meeting/controller/MeetingController.java +++ b/src/main/java/net/teumteum/meeting/controller/MeetingController.java @@ -2,14 +2,12 @@ import lombok.RequiredArgsConstructor; import net.teumteum.core.error.ErrorResponse; -import net.teumteum.meeting.domain.Meeting; -import net.teumteum.meeting.model.PageDto; import net.teumteum.meeting.domain.Topic; import net.teumteum.meeting.domain.response.MeetingResponse; import net.teumteum.meeting.domain.response.MeetingsResponse; +import net.teumteum.meeting.model.PageDto; import net.teumteum.meeting.service.MeetingService; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -35,9 +33,7 @@ public PageDto getMeetingsOrderByDate(Pageable pageable, @RequestParam(value = "participantUserId", required = false) Long participantUserId, @RequestParam(value = "searchWord", required = false) String searchWord) { - Slice meetings = meetingService.getMeetingsBySpecification(pageable, topic, meetingAreaStreet, participantUserId, searchWord, isOpen); - - return PageDto.of(MeetingsResponse.of(meetings.getContent()), meetings.hasNext()); + return meetingService.getMeetingsBySpecification(pageable, topic, meetingAreaStreet, participantUserId, searchWord, isOpen); } @ResponseStatus(HttpStatus.BAD_REQUEST) diff --git a/src/main/java/net/teumteum/meeting/service/MeetingService.java b/src/main/java/net/teumteum/meeting/service/MeetingService.java index e2c32125..9e39a2ac 100644 --- a/src/main/java/net/teumteum/meeting/service/MeetingService.java +++ b/src/main/java/net/teumteum/meeting/service/MeetingService.java @@ -6,8 +6,9 @@ import net.teumteum.meeting.domain.MeetingSpecification; import net.teumteum.meeting.domain.Topic; import net.teumteum.meeting.domain.response.MeetingResponse; +import net.teumteum.meeting.domain.response.MeetingsResponse; +import net.teumteum.meeting.model.PageDto; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -27,8 +28,8 @@ public MeetingResponse getMeetingById(Long meetingId) { } @Transactional(readOnly = true) - public Slice getMeetingsBySpecification(Pageable pageable, Topic topic, String meetingAreaStreet, - Long participantUserId, String searchWord, boolean isOpen) { + public PageDto getMeetingsBySpecification(Pageable pageable, Topic topic, String meetingAreaStreet, + Long participantUserId, String searchWord, boolean isOpen) { Specification spec = MeetingSpecification.withIsOpen(isOpen); @@ -46,7 +47,9 @@ else if (searchWord != null) { .and(MeetingSpecification.withIsOpen(isOpen)); } - return meetingRepository.findAll(spec, pageable); + var meetings = meetingRepository.findAll(spec, pageable); + + return PageDto.of(MeetingsResponse.of(meetings.getContent()), meetings.hasNext()); } }