From a467f24a41715a79311aff48006505dceb404f07 Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:02:32 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[REFATOR]=20attendance=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/attendance/api/AppAttendanceApi.java | 4 ++-- .../api/AppAttendanceApiController.java | 5 ++--- .../dto/request/LectureAttendRequest.java | 9 +++++++++ .../dto/response/LectureAttendResponse.java | 15 +++++++++++++++ .../attendance/service/AppAttendanceService.java | 6 +++--- .../service/AppAttendanceServiceImpl.java | 8 ++++---- 6 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/LectureAttendRequest.java create mode 100644 operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApi.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApi.java index 28ba0ef9..cf6c86cb 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApi.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApi.java @@ -2,7 +2,7 @@ import java.security.Principal; -import org.sopt.makers.operation.app.attendance.dto.request.AttendanceRequest; +import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest; import org.sopt.makers.operation.dto.BaseResponse; import org.springframework.http.ResponseEntity; @@ -36,6 +36,6 @@ public interface AppAttendanceApi { } ) ResponseEntity> attend( - @RequestBody AttendanceRequest request, + @RequestBody LectureAttendRequest request, @Parameter(hidden = true) @NonNull Principal principal); } diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApiController.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApiController.java index 627fd9de..0415f03b 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApiController.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/api/AppAttendanceApiController.java @@ -4,7 +4,7 @@ import java.security.Principal; -import org.sopt.makers.operation.app.attendance.dto.request.AttendanceRequest; +import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest; import org.sopt.makers.operation.app.attendance.service.AppAttendanceService; import org.sopt.makers.operation.common.util.CommonUtils; import org.sopt.makers.operation.util.ApiResponseUtil; @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.val; @@ -29,7 +28,7 @@ public class AppAttendanceApiController implements AppAttendanceApi { @Override @PostMapping("/attend") - public ResponseEntity> attend(@RequestBody AttendanceRequest request, @NonNull Principal principal) { + public ResponseEntity> attend(@RequestBody LectureAttendRequest request, Principal principal) { val memberId = utils.getMemberId(principal); val response = attendanceService.attend(memberId, request); return ApiResponseUtil.success(SUCCESS_ATTEND, response); diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/LectureAttendRequest.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/LectureAttendRequest.java new file mode 100644 index 00000000..794dd562 --- /dev/null +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/LectureAttendRequest.java @@ -0,0 +1,9 @@ +package org.sopt.makers.operation.app.attendance.dto.request; + +import lombok.NonNull; + +public record LectureAttendRequest( + long subLectureId, + @NonNull String code +) { +} diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java new file mode 100644 index 00000000..5a50ea63 --- /dev/null +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java @@ -0,0 +1,15 @@ +package org.sopt.makers.operation.app.attendance.dto.response; + +import lombok.Builder; +import org.sopt.makers.operation.attendance.domain.SubAttendance; + +@Builder +public record LectureAttendResponse( + Long subLectureId +) { + public static LectureAttendResponse of(SubAttendance subAttendance) { + return LectureAttendResponse.builder() + .subLectureId(subAttendance.getSubLecture().getId()) + .build(); + } +} diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceService.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceService.java index 5c14a275..3d0c5668 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceService.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceService.java @@ -1,8 +1,8 @@ package org.sopt.makers.operation.app.attendance.service; -import org.sopt.makers.operation.app.attendance.dto.request.AttendanceRequest; -import org.sopt.makers.operation.app.attendance.dto.response.AttendanceResponse; +import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest; +import org.sopt.makers.operation.app.attendance.dto.response.LectureAttendResponse; public interface AppAttendanceService { - AttendanceResponse attend(long memberId, AttendanceRequest request); + LectureAttendResponse attend(long memberId, LectureAttendRequest request); } diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceServiceImpl.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceServiceImpl.java index 7978e904..a72dee33 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceServiceImpl.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/service/AppAttendanceServiceImpl.java @@ -6,8 +6,8 @@ import static org.sopt.makers.operation.code.failure.lecture.LectureFailureCode.*; import static org.sopt.makers.operation.code.failure.subLecture.subLectureFailureCode.*; -import org.sopt.makers.operation.app.attendance.dto.request.AttendanceRequest; -import org.sopt.makers.operation.app.attendance.dto.response.AttendanceResponse; +import org.sopt.makers.operation.app.attendance.dto.request.LectureAttendRequest; +import org.sopt.makers.operation.app.attendance.dto.response.LectureAttendResponse; import org.sopt.makers.operation.attendance.domain.Attendance; import org.sopt.makers.operation.attendance.domain.SubAttendance; import org.sopt.makers.operation.attendance.repository.attendance.AttendanceRepository; @@ -39,10 +39,10 @@ public class AppAttendanceServiceImpl implements AppAttendanceService { @Override @Transactional - public AttendanceResponse attend(long playgroundId, AttendanceRequest request) { + public LectureAttendResponse attend(long playgroundId, LectureAttendRequest request) { val subAttendance = getSubAttendance(request.subLectureId(), request.code(), playgroundId); subAttendance.updateStatus(ATTENDANCE); - return AttendanceResponse.of(subAttendance); + return LectureAttendResponse.of(subAttendance); } private SubAttendance getSubAttendance(long subLectureId, String code, long playgroundId) { From 492ef6d6b6c63a099d00f8e5e419c11a752097ce Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:03:04 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[REFATOR]=20member=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/member/dto/response/AttendanceTotalResponseDTO.java | 1 - .../operation/app/member/service/AppMemberServiceImpl.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java index d0c010ba..8758e2ff 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java @@ -2,7 +2,6 @@ import java.util.List; -import org.sopt.makers.operation.app.attendance.dto.response.AttendanceTotalVO; import org.sopt.makers.operation.common.domain.Part; import org.sopt.makers.operation.member.domain.Member; diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/member/service/AppMemberServiceImpl.java b/operation-api/src/main/java/org/sopt/makers/operation/app/member/service/AppMemberServiceImpl.java index 7cdab0e9..f56a849a 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/member/service/AppMemberServiceImpl.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/member/service/AppMemberServiceImpl.java @@ -7,7 +7,7 @@ import java.util.List; import org.sopt.makers.operation.app.member.dto.response.AttendanceTotalResponseDTO; -import org.sopt.makers.operation.app.attendance.dto.response.AttendanceTotalVO; +import org.sopt.makers.operation.app.member.dto.response.AttendanceTotalVO; import org.sopt.makers.operation.app.member.dto.response.MemberScoreGetResponse; import org.sopt.makers.operation.attendance.repository.attendance.AttendanceRepository; import org.sopt.makers.operation.config.ValueConfig; From 3f3e9fc30d973d3d492f5baae85625fe490a7571 Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:04:03 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[REFATOR]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20DTO=20=EC=A0=9C=EA=B1=B0,=20member=20DTO=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attendance/dto/request/AttendanceRequest.java | 9 --------- .../attendance/dto/response/AttendanceResponse.java | 12 ------------ .../dto/response/AttendanceTotalVO.java | 2 +- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/AttendanceRequest.java delete mode 100644 operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceResponse.java rename operation-api/src/main/java/org/sopt/makers/operation/app/{attendance => member}/dto/response/AttendanceTotalVO.java (94%) diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/AttendanceRequest.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/AttendanceRequest.java deleted file mode 100644 index 04df0c1c..00000000 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/request/AttendanceRequest.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.sopt.makers.operation.app.attendance.dto.request; - -import lombok.NonNull; - -public record AttendanceRequest( - long subLectureId, - @NonNull String code -) { -} diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceResponse.java deleted file mode 100644 index 20a398ce..00000000 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceResponse.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.sopt.makers.operation.app.attendance.dto.response; - -import org.sopt.makers.operation.attendance.domain.SubAttendance; - -public record AttendanceResponse( - Long subLectureId -) { - - public static AttendanceResponse of(SubAttendance subAttendance) { - return new AttendanceResponse(subAttendance.getSubLecture().getId()); - } -} diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceTotalVO.java b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalVO.java similarity index 94% rename from operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceTotalVO.java rename to operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalVO.java index e111af62..e9754509 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/AttendanceTotalVO.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalVO.java @@ -1,4 +1,4 @@ -package org.sopt.makers.operation.app.attendance.dto.response; +package org.sopt.makers.operation.app.member.dto.response; import java.time.format.DateTimeFormatter; From 2452b71855a7f71719d6072a7b4004fc0badada9 Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:04:32 +0900 Subject: [PATCH 4/6] =?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); From 9d03d55a73ecce3bd3c8822ca27655c75cca7a1b Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:33:43 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[FIX]=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81:=20=EC=9B=90=EC=8B=9C=ED=83=80?= =?UTF-8?q?=EC=9E=85,=20PRIVATE=20=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/LectureAttendResponse.java | 7 +++++-- .../response/LectureCurrentRoundResponse.java | 14 ++++++++----- .../dto/response/TodayLectureResponse.java | 21 ++++++++++++++++--- .../service/AppLectureServiceImpl.java | 15 +------------ .../response/AttendanceTotalResponseDTO.java | 20 +++++++++++------- .../dto/response/MemberScoreGetResponse.java | 11 +++++++--- 6 files changed, 53 insertions(+), 35 deletions(-) diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java index 5a50ea63..442b05b3 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/attendance/dto/response/LectureAttendResponse.java @@ -1,11 +1,14 @@ package org.sopt.makers.operation.app.attendance.dto.response; +import static lombok.AccessLevel.*; + import lombok.Builder; + import org.sopt.makers.operation.attendance.domain.SubAttendance; -@Builder +@Builder(access = PRIVATE) public record LectureAttendResponse( - Long subLectureId + long subLectureId ) { public static LectureAttendResponse of(SubAttendance subAttendance) { return LectureAttendResponse.builder() diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/LectureCurrentRoundResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/LectureCurrentRoundResponse.java index fec03c1f..231ea7c9 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/LectureCurrentRoundResponse.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/LectureCurrentRoundResponse.java @@ -1,15 +1,19 @@ package org.sopt.makers.operation.app.lecture.dto.response; +import lombok.Builder; import org.sopt.makers.operation.lecture.domain.SubLecture; +import static lombok.AccessLevel.PRIVATE; + +@Builder(access = PRIVATE) public record LectureCurrentRoundResponse( - Long id, + long id, int round ) { public static LectureCurrentRoundResponse of(SubLecture subLecture){ - return new LectureCurrentRoundResponse( - subLecture.getId(), - subLecture.getRound() - ); + return LectureCurrentRoundResponse.builder() + .id(subLecture.getId()) + .round(subLecture.getRound()) + .build(); } } diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/TodayLectureResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/TodayLectureResponse.java index bfe8d1b4..e5de11eb 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/TodayLectureResponse.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/lecture/dto/response/TodayLectureResponse.java @@ -2,19 +2,22 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import static lombok.AccessLevel.*; + import org.sopt.makers.operation.attendance.domain.AttendanceStatus; import org.sopt.makers.operation.attendance.domain.SubAttendance; import org.sopt.makers.operation.lecture.domain.Lecture; import lombok.Builder; -@Builder +@Builder(access = PRIVATE) public record TodayLectureResponse( LectureResponseType type, - Long id, + long id, String location, String name, String startDate, @@ -23,7 +26,6 @@ public record TodayLectureResponse( List attendances ) { public static TodayLectureResponse of(LectureResponseType type, Lecture lecture, String message, List attendances) { - return TodayLectureResponse.builder() .type(type) .id(lecture.getId()) @@ -38,6 +40,19 @@ public static TodayLectureResponse of(LectureResponseType type, Lecture lecture, .build(); } + public static TodayLectureResponse getEmptyResponse() { + return TodayLectureResponse.builder() + .type(LectureResponseType.NO_SESSION) + .id(0L) + .location("") + .name("") + .startDate("") + .endDate("") + .message("") + .attendances(Collections.emptyList()) + .build(); + } + private static DateTimeFormatter convertFormat() { return DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"); } 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 2d1c3442..ee895ffb 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 @@ -46,7 +46,7 @@ public TodayLectureResponse getTodayLecture(long memberPlaygroundId) { checkAttendancesSize(attendances); if (attendances.isEmpty()) { - return getEmptyResponse(); + return TodayLectureResponse.getEmptyResponse(); } val attendance = getNowAttendance(attendances); @@ -67,19 +67,6 @@ public TodayLectureResponse getTodayLecture(long memberPlaygroundId) { return getTodaySecondLectureResponse(subAttendances, responseType, lecture); } - private TodayLectureResponse getEmptyResponse() { - return TodayLectureResponse.builder() - .type(LectureResponseType.NO_SESSION) - .id(0L) - .location("") - .name("") - .startDate("") - .endDate("") - .message("") - .attendances(Collections.emptyList()) - .build(); - } - private void checkAttendancesSize(List attendances) { if (attendances.size() > valueConfig.getSUB_LECTURE_MAX_ROUND()) { throw new LectureException(INVALID_COUNT_SESSION); diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java index 8758e2ff..1bf8f22a 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/AttendanceTotalResponseDTO.java @@ -2,9 +2,13 @@ import java.util.List; +import lombok.Builder; import org.sopt.makers.operation.common.domain.Part; import org.sopt.makers.operation.member.domain.Member; +import static lombok.AccessLevel.PRIVATE; + +@Builder(access = PRIVATE) public record AttendanceTotalResponseDTO( Part part, int generation, @@ -14,14 +18,14 @@ public record AttendanceTotalResponseDTO( List attendances ) { public static AttendanceTotalResponseDTO of(Member member, List attendances){ - return new AttendanceTotalResponseDTO( - member.getPart(), - member.getGeneration(), - member.getName(), - member.getScore(), - getTotal(member), - attendances - ); + return AttendanceTotalResponseDTO.builder() + .part(member.getPart()) + .generation(member.getGeneration()) + .name(member.getName()) + .score(member.getScore()) + .total(getTotal(member)) + .attendances(attendances) + .build(); } private static AttendanceStatusListVO getTotal(Member member) { diff --git a/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/MemberScoreGetResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/MemberScoreGetResponse.java index c15151bc..6dfc6601 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/MemberScoreGetResponse.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/app/member/dto/response/MemberScoreGetResponse.java @@ -1,11 +1,16 @@ package org.sopt.makers.operation.app.member.dto.response; +import static lombok.AccessLevel.PRIVATE; + +import lombok.Builder; + +@Builder(access = PRIVATE) public record MemberScoreGetResponse( float score ) { public static MemberScoreGetResponse of(float score){ - return new MemberScoreGetResponse( - score - ); + return MemberScoreGetResponse.builder() + .score(score) + .build(); } } From dca3eda1469e2f5890e53fd9a42580664f449da9 Mon Sep 17 00:00:00 2001 From: dragontaek-lee Date: Fri, 16 Feb 2024 00:39:00 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[REFACTOR]=20=EC=B6=9C=EC=84=9D=20=EC=A4=91?= =?UTF-8?q?=20=EA=B2=B0=EC=84=9D=20=ED=8C=90=EB=B3=84=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/lecture/service/AppLectureServiceImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 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 ee895ffb..7f5fe825 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 @@ -73,6 +73,11 @@ private void checkAttendancesSize(List attendances) { } } + private boolean checkOnAttendanceAbsence(SubLecture subLecture, SubAttendance subAttendance) { + val isOnAttendanceCheck = LocalDateTime.now().isBefore(subLecture.getStartAt().plusMinutes(10)); + return isOnAttendanceCheck && subAttendance.getStatus().equals(ABSENT); + } + private Attendance getNowAttendance(List attendances) { val index = getAttendanceIndex(); return attendances.get(index); @@ -97,9 +102,8 @@ private String getMessage(Attribute attribute) { 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()); - if (isOnAttendanceCheck && subAttendance.getStatus().equals(ABSENT)) { + if (checkOnAttendanceAbsence(subLecture, subAttendance)) { return TodayLectureResponse.of(responseType, lecture, message, Collections.emptyList()); } return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendance)); @@ -112,9 +116,8 @@ private TodayLectureResponse getTodaySecondLectureResponse( ) { 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)) { + if (checkOnAttendanceAbsence(subLecture, subAttendance)) { return TodayLectureResponse.of(responseType, lecture, message, Collections.singletonList(subAttendances.get(0))); } return TodayLectureResponse.of(responseType, lecture, message, subAttendances);