From 2452b71855a7f71719d6072a7b4004fc0badada9 Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:04:32 +0900 Subject: [PATCH] =?UTF-8?q?[REFATOR]=20=EB=8B=B9=EC=9D=BC=20=EC=B6=9C?= =?UTF-8?q?=EC=84=9D=20=EC=A0=95=EB=B3=B4=20=EB=88=84=EB=9D=BD=EB=90=9C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AppLectureServiceImpl.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/service/AppLectureServiceImpl.java b/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/service/AppLectureServiceImpl.java index df0fd4d5..2d1c3442 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/service/AppLectureServiceImpl.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/service/AppLectureServiceImpl.java @@ -59,8 +59,12 @@ public TodayLectureResponse getTodayLecture(long memberPlaygroundId) { } val subAttendances = attendance.getSubAttendances(); - val subAttendance = lecture.isFirst() ? subAttendances.get(0) : subAttendances.get(1); - return getTodayLectureResponse(subAttendance, responseType, lecture); + + if (lecture.isFirst()) { + return getTodayFirstLectureResponse(subAttendances.get(0), responseType, lecture); + } + + return getTodaySecondLectureResponse(subAttendances, responseType, lecture); } private TodayLectureResponse getEmptyResponse() { @@ -104,7 +108,7 @@ private String getMessage(Attribute attribute) { }; } - private TodayLectureResponse getTodayLectureResponse(SubAttendance subAttendance, LectureResponseType responseType, Lecture lecture) { + private TodayLectureResponse getTodayFirstLectureResponse(SubAttendance subAttendance, LectureResponseType responseType, Lecture lecture) { val subLecture = subAttendance.getSubLecture(); val isOnAttendanceCheck = LocalDateTime.now().isBefore(subLecture.getStartAt().plusMinutes(10)); val message = getMessage(lecture.getAttribute()); @@ -114,6 +118,21 @@ private TodayLectureResponse getTodayLectureResponse(SubAttendance subAttendance return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendance)); } + private TodayLectureResponse getTodaySecondLectureResponse( + List subAttendances, + LectureResponseType responseType, + Lecture lecture + ) { + val subAttendance = subAttendances.get(1); + val subLecture = subAttendance.getSubLecture(); + val isOnAttendanceCheck = LocalDateTime.now().isBefore(subLecture.getStartAt().plusMinutes(10)); + val message = getMessage(lecture.getAttribute()); + if (isOnAttendanceCheck && subAttendance.getStatus().equals(ABSENT)) { + return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendances.get(0))); + } + return TodayLectureResponse.of(responseType, lecture, message, subAttendances); + } + @Override public LectureCurrentRoundResponse getCurrentLectureRound(long lectureId) { val lecture = findLecture(lectureId);