-
Notifications
You must be signed in to change notification settings - Fork 1
[WTH-83] 출석 관리 페이지에서 이번주차 반환 #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "WTH-83-weeth-\uCD9C\uC11D-\uAD00\uB9AC-\uC8FC\uCC28\uC5D0\uC11C-\uC774\uBC88-\uC8FC\uCC28-\uBC18\uD658"
Changes from 3 commits
ed18147
6ced669
8202115
f61a4bd
ce00ce9
eff47b5
63c46ed
3136b43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| import leets.weeth.domain.schedule.application.mapper.MeetingMapper; | ||
| import leets.weeth.domain.schedule.domain.entity.Meeting; | ||
| import leets.weeth.domain.schedule.domain.service.MeetingDeleteService; | ||
| import leets.weeth.domain.schedule.domain.service.MeetingDomainService; | ||
| import leets.weeth.domain.schedule.domain.service.MeetingGetService; | ||
| import leets.weeth.domain.schedule.domain.service.MeetingSaveService; | ||
| import leets.weeth.domain.schedule.domain.service.MeetingUpdateService; | ||
|
|
@@ -24,6 +25,11 @@ | |
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.time.DayOfWeek; | ||
| import java.time.LocalDate; | ||
| import java.time.temporal.TemporalAdjusters; | ||
| import java.util.ArrayList; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
|
|
||
| import static leets.weeth.domain.schedule.application.dto.MeetingDTO.Info; | ||
|
|
@@ -40,6 +46,7 @@ public class MeetingUseCaseImpl implements MeetingUseCase { | |
| private final UserGetService userGetService; | ||
| private final MeetingUpdateService meetingUpdateService; | ||
| private final MeetingDeleteService meetingDeleteService; | ||
| private final MeetingDomainService meetingDomainService; | ||
| private final AttendanceGetService attendanceGetService; | ||
| private final AttendanceSaveService attendanceSaveService; | ||
| private final AttendanceDeleteService attendanceDeleteService; | ||
|
|
@@ -64,6 +71,7 @@ public Response find(Long userId, Long meetingId) { | |
| @Override | ||
| public List<Info> find(Integer cardinal) { | ||
| List<Meeting> meetings; | ||
| List<Info> result = new ArrayList<>(); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (cardinal == null) { | ||
| meetings = meetingGetService.findAll(); | ||
|
|
@@ -73,9 +81,11 @@ public List<Info> find(Integer cardinal) { | |
|
|
||
| } | ||
|
|
||
| return meetings.stream() | ||
| .map(mapper::toInfo) | ||
| .toList(); | ||
| List<Meeting> ordered = meetingDomainService.reorderMeetingsWithThisWeek(meetings); | ||
|
||
|
|
||
| return ordered.stream() | ||
| .map(mapper::toInfo) | ||
| .toList(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package leets.weeth.domain.schedule.domain.service; | ||
|
|
||
| import java.time.DayOfWeek; | ||
| import java.time.LocalDate; | ||
| import java.time.temporal.TemporalAdjusters; | ||
| import java.util.ArrayList; | ||
| import java.util.Comparator; | ||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import leets.weeth.domain.schedule.domain.entity.Meeting; | ||
|
|
||
| @Service | ||
| public class MeetingDomainService { | ||
|
||
|
|
||
| public List<Meeting> reorderMeetingsWithThisWeek(List<Meeting> meetings) { | ||
|
|
||
| LocalDate today = LocalDate.now(); | ||
| LocalDate startOfWeek = today.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)); | ||
| LocalDate endOfWeek = today.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)); | ||
|
|
||
| Meeting thisWeek = meetings.stream() | ||
| .filter(m -> { | ||
| LocalDate date = m.getStart().toLocalDate(); | ||
| return !date.isBefore(startOfWeek) && !date.isAfter(endOfWeek); | ||
| }) | ||
| .findFirst() | ||
| .orElse(null); | ||
|
|
||
| List<Meeting> result = new ArrayList<>(); | ||
|
|
||
| if (thisWeek != null) { | ||
| result.add(thisWeek); | ||
| } | ||
|
|
||
| result.addAll( | ||
| meetings.stream() | ||
| .sorted(Comparator.comparing(Meeting::getStart).reversed()) | ||
| .toList() | ||
| ); | ||
|
||
|
|
||
| return result; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요기 import문은 왜 들어갔을까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음에 기능을 useCaseImpl에 작성을 하고 난 뒤 파일 분리해서 구현하느라 삭제를 깜빡했습니다!
지우겠습니다 👍🏻