From 899d0b4869ea649f7e926ce6a8d42a3c35d8ee7c Mon Sep 17 00:00:00 2001 From: seulgi99 Date: Mon, 26 Aug 2024 11:45:51 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=EC=A3=BC=EC=B0=A8=EB=B3=84=20=EC=B6=9C=EA=B2=B0=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/MentorStudyDetailController.java | 9 +++++++++ .../application/MentorStudyDetailService.java | 15 +++++++++++++++ .../StudyMentorAttendanceResponse.java | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyMentorAttendanceResponse.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java index bc74e9a7b..bf3c28319 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java @@ -3,6 +3,7 @@ import com.gdschongik.gdsc.domain.study.application.MentorStudyDetailService; import com.gdschongik.gdsc.domain.study.dto.request.AssignmentCreateUpdateRequest; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse; +import com.gdschongik.gdsc.domain.study.dto.response.StudyMentorAttendanceResponse; import com.gdschongik.gdsc.domain.study.dto.response.StudySessionResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -71,4 +72,12 @@ public ResponseEntity> getStudySessions(@RequestParam List response = mentorStudyDetailService.getSessions(studyId); return ResponseEntity.ok(response); } + + @Operation(summary = "스터디 주차별 출결번호 조회", description = "멘토가 자신의 스터디 출결번호 목록을 조회합니다. 지난 출석은 목록에서 제외합니다.") + @GetMapping("/attendances") + public ResponseEntity> getAttendanceNumber( + @RequestParam(name = "study") Long studyId) { + List response = mentorStudyDetailService.getAttendanceNumber(studyId); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java index b6bb9dbb5..f78e66db6 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java @@ -8,9 +8,11 @@ import com.gdschongik.gdsc.domain.study.domain.StudyDetailValidator; import com.gdschongik.gdsc.domain.study.dto.request.AssignmentCreateUpdateRequest; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse; +import com.gdschongik.gdsc.domain.study.dto.response.StudyMentorAttendanceResponse; import com.gdschongik.gdsc.domain.study.dto.response.StudySessionResponse; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.util.MemberUtil; +import java.time.LocalDate; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -90,4 +92,17 @@ public List getSessions(Long studyId) { List studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId); return studyDetails.stream().map(StudySessionResponse::from).toList(); } + + @Transactional(readOnly = true) + public List getAttendanceNumber(Long studyId) { + List studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId); + + // 출석일이 오늘 or 오늘이후 인 StudyDetail + List notAttendedStudyDetails = studyDetails.stream() + .filter(studyDetail -> !studyDetail.getAttendanceDay().isBefore(LocalDate.now())) + .toList(); + return notAttendedStudyDetails.stream() + .map(StudyMentorAttendanceResponse::from) + .toList(); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyMentorAttendanceResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyMentorAttendanceResponse.java new file mode 100644 index 000000000..c33665016 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyMentorAttendanceResponse.java @@ -0,0 +1,19 @@ +package com.gdschongik.gdsc.domain.study.dto.response; + +import com.gdschongik.gdsc.domain.study.domain.StudyDetail; +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDateTime; + +public record StudyMentorAttendanceResponse( + Long studyDetailId, + @Schema(description = "주차수") Long week, + @Schema(description = "마감시각") LocalDateTime deadLine, + @Schema(description = "출석번호") String attendanceNumber) { + public static StudyMentorAttendanceResponse from(StudyDetail studyDetail) { + return new StudyMentorAttendanceResponse( + studyDetail.getId(), + studyDetail.getWeek(), + studyDetail.getAttendanceDay().atTime(23, 59, 59), + studyDetail.getAttendanceNumber()); + } +} From 3d29b9941bd882aa47df4c8be5cbce147a533a31 Mon Sep 17 00:00:00 2001 From: seulgi99 Date: Mon, 26 Aug 2024 11:51:06 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20=EB=A6=AC=ED=80=98=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/api/MentorStudyDetailController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java index bf3c28319..9245303e5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java @@ -68,7 +68,7 @@ public ResponseEntity cancelStudyAssignment(@PathVariable Long studyDetail // TODO 스터디 세션 워딩을 커리큘럼으로 변경해야함 @Operation(summary = "스터디 주차별 커리큘럼 목록 조회", description = "멘토가 자신의 스터디 커리큘럼 목록을 조회합니다") @GetMapping("/sessions") - public ResponseEntity> getStudySessions(@RequestParam(name = "study") Long studyId) { + public ResponseEntity> getStudySessions(@RequestParam(name = "studyId") Long studyId) { List response = mentorStudyDetailService.getSessions(studyId); return ResponseEntity.ok(response); } @@ -76,7 +76,7 @@ public ResponseEntity> getStudySessions(@RequestParam @Operation(summary = "스터디 주차별 출결번호 조회", description = "멘토가 자신의 스터디 출결번호 목록을 조회합니다. 지난 출석은 목록에서 제외합니다.") @GetMapping("/attendances") public ResponseEntity> getAttendanceNumber( - @RequestParam(name = "study") Long studyId) { + @RequestParam(name = "studyId") Long studyId) { List response = mentorStudyDetailService.getAttendanceNumber(studyId); return ResponseEntity.ok(response); } From 4a5f3d38ebf281fca79793b4224955df7ef7295f Mon Sep 17 00:00:00 2001 From: seulgi99 Date: Mon, 26 Aug 2024 15:03:32 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=EC=B6=9C=EC=84=9D=EC=9D=BC=EC=9E=90=20=EC=A7=80=EB=82=AC?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=8C=90=EB=8B=A8=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/api/MentorStudyDetailController.java | 4 ++-- .../study/application/MentorStudyDetailService.java | 10 ++++------ .../gdsc/domain/study/domain/StudyDetail.java | 5 +++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java index 9245303e5..9a961a4e7 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java @@ -75,9 +75,9 @@ public ResponseEntity> getStudySessions(@RequestParam @Operation(summary = "스터디 주차별 출결번호 조회", description = "멘토가 자신의 스터디 출결번호 목록을 조회합니다. 지난 출석은 목록에서 제외합니다.") @GetMapping("/attendances") - public ResponseEntity> getAttendanceNumber( + public ResponseEntity> getAttendanceNumbers( @RequestParam(name = "studyId") Long studyId) { - List response = mentorStudyDetailService.getAttendanceNumber(studyId); + List response = mentorStudyDetailService.getAttendanceNumbers(studyId); return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java index f78e66db6..93272d724 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java @@ -94,14 +94,12 @@ public List getSessions(Long studyId) { } @Transactional(readOnly = true) - public List getAttendanceNumber(Long studyId) { + public List getAttendanceNumbers(Long studyId) { List studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId); - // 출석일이 오늘 or 오늘이후 인 StudyDetail - List notAttendedStudyDetails = studyDetails.stream() - .filter(studyDetail -> !studyDetail.getAttendanceDay().isBefore(LocalDate.now())) - .toList(); - return notAttendedStudyDetails.stream() + // 출석일이 오늘 or 오늘이후인 StudyDetail + return studyDetails.stream() + .filter(studyDetail -> studyDetail.isAttendanceDayPassed(LocalDate.now())) .map(StudyMentorAttendanceResponse::from) .toList(); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java index 41bb4a0b5..c8f8d92d7 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java @@ -123,6 +123,11 @@ public LocalDate getAttendanceDay() { return startDate.plusDays(daysToAdd); } + // 출석일이 오늘 or 오늘이후인지 확인 + public boolean isAttendanceDayPassed(LocalDate now) { + return !getAttendanceDay().isBefore(now); + } + public void updateSession( LocalTime startAt, String title, String description, Difficulty difficulty, StudyStatus status) { session = Session.generateSession(startAt, title, description, difficulty, status); From 2c3f66348af6d7ab5db25a4cd9ae94c56af87723 Mon Sep 17 00:00:00 2001 From: seulgi99 Date: Mon, 26 Aug 2024 15:11:57 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=EC=B6=9C=EC=84=9D=EC=9D=BC=20?= =?UTF-8?q?=EC=A7=80=EB=82=A8=20=EC=97=AC=EB=B6=80=20=ED=8C=90=EB=8B=A8=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/application/MentorStudyDetailService.java | 2 +- .../com/gdschongik/gdsc/domain/study/domain/StudyDetail.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java index 93272d724..629608cb3 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java @@ -99,7 +99,7 @@ public List getAttendanceNumbers(Long studyId) { // 출석일이 오늘 or 오늘이후인 StudyDetail return studyDetails.stream() - .filter(studyDetail -> studyDetail.isAttendanceDayPassed(LocalDate.now())) + .filter(studyDetail -> studyDetail.isAttendanceDayNotPassed(LocalDate.now())) .map(StudyMentorAttendanceResponse::from) .toList(); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java index c8f8d92d7..c2b0c4cc5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java @@ -124,7 +124,7 @@ public LocalDate getAttendanceDay() { } // 출석일이 오늘 or 오늘이후인지 확인 - public boolean isAttendanceDayPassed(LocalDate now) { + public boolean isAttendanceDayNotPassed(LocalDate now) { return !getAttendanceDay().isBefore(now); }