From 21dcdd7a1ff95450fc9c903b9b9971aac5eb8764 Mon Sep 17 00:00:00 2001 From: Hanbee_Lee Date: Sun, 18 Aug 2024 22:30:29 +0900 Subject: [PATCH 01/14] =?UTF-8?q?feat:=20=EC=9D=B4=EB=B2=88=EC=A3=BC=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=9C=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/StudentStudyDetailController.java | 10 +++++ .../StudentStudyDetailService.java | 13 +++++++ .../response/AssignmentStatusResponse.java | 37 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java index 1f8eeed52..710119671 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java @@ -2,8 +2,10 @@ import com.gdschongik.gdsc.domain.study.application.StudentStudyDetailService; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentDashboardResponse; +import com.gdschongik.gdsc.domain.study.dto.response.AssignmentStatusResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -26,4 +28,12 @@ public ResponseEntity getSubmittableAssignments( AssignmentDashboardResponse response = studentStudyDetailService.getSubmittableAssignments(studyId); return ResponseEntity.ok(response); } + + @Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.") + @GetMapping("/assignments") + public ResponseEntity> getAssignmentsToSubmit( + @RequestParam(name = "studyId") Long studyId) { + List response = studentStudyDetailService.getAssignmentsToSubmit(studyId); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index 36fac587c..ee08ed65a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -6,6 +6,7 @@ import com.gdschongik.gdsc.domain.study.domain.AssignmentHistory; import com.gdschongik.gdsc.domain.study.domain.StudyHistory; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentDashboardResponse; +import com.gdschongik.gdsc.domain.study.dto.response.AssignmentStatusResponse; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentSubmittableDto; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.exception.ErrorCode; @@ -40,4 +41,16 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { return AssignmentDashboardResponse.of(studyHistory.getRepositoryLink(), isAnySubmitted, submittableAssignments); } + + @Transactional(readOnly = true) + public List getAssignmentsToSubmit(Long studyId) { + Member currentMember = memberUtil.getCurrentMember(); + List assignmentHistories = + assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudy(currentMember, studyId).stream() + .filter(assignmentHistory -> + assignmentHistory.getStudyDetail().isAssignmentDeadlineRemaining()) + .toList(); + + return assignmentHistories.stream().map(AssignmentStatusResponse::from).toList(); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java new file mode 100644 index 000000000..89d31d210 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java @@ -0,0 +1,37 @@ +package com.gdschongik.gdsc.domain.study.dto.response; + +import com.gdschongik.gdsc.domain.study.domain.*; +import com.gdschongik.gdsc.domain.study.domain.vo.Assignment; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.annotation.Nullable; +import java.time.LocalDateTime; + +public record AssignmentStatusResponse( + Long studyDetailId, + @Schema(description = "과제 상태") StudyStatus assignmentStatus, + @Schema(description = "주차") Long week, + @Nullable @Schema(description = "과제 제목") String title, + @Nullable @Schema(description = "과제 제출 상태") AssignmentSubmissionStatus assignmentSubmissionStatus, + @Nullable @Schema(description = "과제 명세 링크") String descriptionLink, + @Nullable @Schema(description = "마감 기한") LocalDateTime deadline, + @Nullable @Schema(description = "과제 제출 링크") String submissionLink, + @Nullable @Schema(description = "과제 제출 실패 사유") SubmissionFailureType submissionFailureType, + @Nullable @Schema(description = "최종 수정 일시") LocalDateTime committedAt) { + public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) { + StudyDetail studyDetail = assignmentHistory.getStudyDetail(); + Assignment assignment = studyDetail.getAssignment(); + return new AssignmentStatusResponse( + studyDetail.getId(), + assignment.getStatus(), + studyDetail.getWeek(), + assignment.getTitle(), + assignmentHistory.getSubmissionStatus(), + assignment.getDescriptionLink(), + assignment.getDeadline(), + assignmentHistory.getSubmissionLink(), + assignmentHistory.getSubmissionFailureType() == null + ? null + : assignmentHistory.getSubmissionFailureType(), + assignmentHistory.getCommittedAt() == null ? null : assignmentHistory.getCommittedAt()); + } +} From dc175366f2c0e852f84fcf91ad5734a24f1ef50b Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Tue, 20 Aug 2024 20:21:23 +0900 Subject: [PATCH 02/14] =?UTF-8?q?feat:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=20=EC=97=94=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/api/StudentStudyDetailController.java | 2 +- .../study/dto/response/AssignmentStatusResponse.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java index 710119671..2e7dbc53c 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java @@ -30,7 +30,7 @@ public ResponseEntity getSubmittableAssignments( } @Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.") - @GetMapping("/assignments") + @GetMapping("/assignments/upcoming") public ResponseEntity> getAssignmentsToSubmit( @RequestParam(name = "studyId") Long studyId) { List response = studentStudyDetailService.getAssignmentsToSubmit(studyId); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java index 89d31d210..d25a24cb6 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java @@ -11,6 +11,7 @@ public record AssignmentStatusResponse( @Schema(description = "과제 상태") StudyStatus assignmentStatus, @Schema(description = "주차") Long week, @Nullable @Schema(description = "과제 제목") String title, + // TODO 추후 처리 예정 @Nullable @Schema(description = "과제 제출 상태") AssignmentSubmissionStatus assignmentSubmissionStatus, @Nullable @Schema(description = "과제 명세 링크") String descriptionLink, @Nullable @Schema(description = "마감 기한") LocalDateTime deadline, @@ -29,9 +30,7 @@ public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) assignment.getDescriptionLink(), assignment.getDeadline(), assignmentHistory.getSubmissionLink(), - assignmentHistory.getSubmissionFailureType() == null - ? null - : assignmentHistory.getSubmissionFailureType(), - assignmentHistory.getCommittedAt() == null ? null : assignmentHistory.getCommittedAt()); + assignmentHistory.getSubmissionFailureType(), + assignmentHistory.getCommittedAt()); } } From f1d9c919c30d3e608ade03201ba71d9386608b5a Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Tue, 20 Aug 2024 21:25:06 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20=EC=BD=94=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/application/StudentStudyDetailService.java | 2 +- .../gdsc/domain/study/dao/AssignmentHistoryRepository.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index ee08ed65a..7f8ede9b6 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -46,7 +46,7 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { public List getAssignmentsToSubmit(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); List assignmentHistories = - assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudy(currentMember, studyId).stream() + assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudyId(currentMember, studyId).stream() .filter(assignmentHistory -> assignmentHistory.getStudyDetail().isAssignmentDeadlineRemaining()) .toList(); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java index 1c882f5ee..29f76cf5a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java @@ -3,10 +3,13 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.study.domain.AssignmentHistory; import com.gdschongik.gdsc.domain.study.domain.StudyDetail; +import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface AssignmentHistoryRepository extends JpaRepository, AssignmentHistoryCustomRepository { public Optional findByMemberAndStudyDetail(Member member, StudyDetail studyDetail); + + List findAssignmentHistoriesByMenteeAndStudyId(Member currentMember, Long studyId); } From 0fe4c064271300fcc4e3430d8d2655295fb2d03f Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Tue, 20 Aug 2024 21:47:54 +0900 Subject: [PATCH 04/14] =?UTF-8?q?fix:=20=EB=A0=88=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/application/StudentStudyDetailService.java | 2 +- .../domain/study/application/StudentStudyHistoryService.java | 2 +- .../domain/study/dao/AssignmentHistoryCustomRepository.java | 2 +- .../study/dao/AssignmentHistoryCustomRepositoryImpl.java | 2 +- .../gdsc/domain/study/dao/AssignmentHistoryRepository.java | 3 --- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index 7f8ede9b6..e12c2d5e1 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -32,7 +32,7 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { .orElseThrow(() -> new CustomException(ErrorCode.STUDY_HISTORY_NOT_FOUND)); List assignmentHistories = - assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudy(currentMember, studyId); + assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudyId(currentMember, studyId); boolean isAnySubmitted = assignmentHistories.stream().anyMatch(AssignmentHistory::isSubmitted); List submittableAssignments = assignmentHistories.stream() .filter(assignmentHistory -> assignmentHistory.getStudyDetail().isAssignmentDeadlineRemaining()) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java index 3712640ac..5b988d228 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyHistoryService.java @@ -74,7 +74,7 @@ private String getOwnerRepo(String repositoryLink) { public List getAllAssignmentHistories(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); - return assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudy(currentMember, studyId).stream() + return assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudyId(currentMember, studyId).stream() .map(AssignmentHistoryResponse::from) .toList(); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepository.java index c0edd00ec..11a86f350 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepository.java @@ -9,5 +9,5 @@ public interface AssignmentHistoryCustomRepository { boolean existsSubmittedAssignmentByMemberAndStudy(Member member, Study study); - List findAssignmentHistoriesByMenteeAndStudy(Member member, Long studyId); + List findAssignmentHistoriesByMenteeAndStudyId(Member member, Long studyId); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepositoryImpl.java index 02d3b57df..f43dabba9 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepositoryImpl.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryCustomRepositoryImpl.java @@ -41,7 +41,7 @@ private BooleanExpression isSubmitted() { } @Override - public List findAssignmentHistoriesByMenteeAndStudy(Member currentMember, Long studyId) { + public List findAssignmentHistoriesByMenteeAndStudyId(Member currentMember, Long studyId) { return queryFactory .selectFrom(assignmentHistory) .join(assignmentHistory.studyDetail, studyDetail) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java index 29f76cf5a..1c882f5ee 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/AssignmentHistoryRepository.java @@ -3,13 +3,10 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.study.domain.AssignmentHistory; import com.gdschongik.gdsc.domain.study.domain.StudyDetail; -import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; public interface AssignmentHistoryRepository extends JpaRepository, AssignmentHistoryCustomRepository { public Optional findByMemberAndStudyDetail(Member member, StudyDetail studyDetail); - - List findAssignmentHistoriesByMenteeAndStudyId(Member currentMember, Long studyId); } From ed8f8d17fffd0142d92bf5681b7ab8cdad895132 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Wed, 21 Aug 2024 19:04:20 +0900 Subject: [PATCH 05/14] =?UTF-8?q?feat:=20=EC=9D=B4=EB=B2=88=EC=A3=BC?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EB=A7=88=EA=B0=90=EC=9D=B8=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=9C=EB=93=A4=20=EB=B0=98=ED=99=98=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 --- .../gdsc/domain/study/api/StudentStudyDetailController.java | 4 ++-- .../domain/study/application/StudentStudyDetailService.java | 4 ++-- .../gdschongik/gdsc/domain/study/domain/StudyDetail.java | 3 +++ .../gdschongik/gdsc/domain/study/domain/vo/Assignment.java | 6 ++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java index 2e7dbc53c..7287cacec 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java @@ -31,9 +31,9 @@ public ResponseEntity getSubmittableAssignments( @Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.") @GetMapping("/assignments/upcoming") - public ResponseEntity> getAssignmentsToSubmit( + public ResponseEntity> getUpcomingAssignments( @RequestParam(name = "studyId") Long studyId) { - List response = studentStudyDetailService.getAssignmentsToSubmit(studyId); + List response = studentStudyDetailService.getUpcomingAssignments(studyId); return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index e12c2d5e1..4ced700c7 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -43,12 +43,12 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { } @Transactional(readOnly = true) - public List getAssignmentsToSubmit(Long studyId) { + public List getUpcomingAssignments(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); List assignmentHistories = assignmentHistoryRepository.findAssignmentHistoriesByMenteeAndStudyId(currentMember, studyId).stream() .filter(assignmentHistory -> - assignmentHistory.getStudyDetail().isAssignmentDeadlineRemaining()) + assignmentHistory.getStudyDetail().isAssignmentDeadlineThisWeek()) .toList(); return assignmentHistories.stream().map(AssignmentStatusResponse::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 860282183..319c8ba10 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 @@ -92,6 +92,9 @@ public void updateAssignment(String title, LocalDateTime deadLine, String descri public boolean isAssignmentDeadlineRemaining() { return assignment.isDeadlineRemaining(); } + public boolean isAssignmentDeadlineThisWeek() { + return assignment.isDeadLineThisWeek(); + } // 스터디 시작일자 + 현재 주차 * 7 + (스터디 요일 - 스터디 기간 시작 요일) public LocalDate getAttendanceDay() { diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java index c64cacfec..f1277e994 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java @@ -91,4 +91,10 @@ public boolean isDeadlineRemaining() { LocalDateTime now = LocalDateTime.now(); return now.isBefore(deadline); } + + public boolean isDeadLineThisWeek() { + LocalDateTime now = LocalDateTime.now(); + + // 구현 후 validator작성 + 테스트 작성 + } } From 15c5bb71f608fd2035e3733b95b201890c7ef8be Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Wed, 21 Aug 2024 19:11:37 +0900 Subject: [PATCH 06/14] =?UTF-8?q?feat:=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/domain/StudyDetail.java | 1 + .../gdsc/domain/study/domain/vo/Assignment.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 bc97e59a3..5c6892eb8 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 @@ -93,6 +93,7 @@ public void updateAssignment(String title, LocalDateTime deadLine, String descri public boolean isAssignmentDeadlineRemaining() { return assignment.isDeadlineRemaining(); } + public boolean isAssignmentDeadlineThisWeek() { return assignment.isDeadLineThisWeek(); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java index f1277e994..70ef39524 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java @@ -11,6 +11,8 @@ import jakarta.persistence.Embeddable; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; +import java.time.DayOfWeek; +import java.time.LocalDate; import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Builder; @@ -93,8 +95,14 @@ public boolean isDeadlineRemaining() { } public boolean isDeadLineThisWeek() { - LocalDateTime now = LocalDateTime.now(); + LocalDate now = LocalDate.now(); // 현재 날짜 + LocalDate deadlineDate = deadline.toLocalDate(); // 마감일의 날짜 부분 + + // 이번 주의 첫 번째 요일과 마지막 요일 가져오기 (월요일 ~ 일요일) + LocalDate startOfWeek = now.with(DayOfWeek.MONDAY); + LocalDate endOfWeek = now.with(DayOfWeek.SUNDAY); - // 구현 후 validator작성 + 테스트 작성 + // 마감일이 이번 주 내에 있는지 확인 + return !deadlineDate.isBefore(startOfWeek) && !deadlineDate.isAfter(endOfWeek); } } From 1b29a9a7423741998f4c233f81399f69460322c6 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Wed, 21 Aug 2024 19:16:44 +0900 Subject: [PATCH 07/14] =?UTF-8?q?feat:=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=A3=BC=EC=84=9D=20=EA=B0=80?= =?UTF-8?q?=EB=8F=85=EC=84=B1=20=ED=96=A5=EC=83=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/domain/vo/Assignment.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java index 70ef39524..2c82a1642 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/vo/Assignment.java @@ -95,12 +95,13 @@ public boolean isDeadlineRemaining() { } public boolean isDeadLineThisWeek() { - LocalDate now = LocalDate.now(); // 현재 날짜 - LocalDate deadlineDate = deadline.toLocalDate(); // 마감일의 날짜 부분 + // 현재 날짜와 마감일의 날짜 부분을 비교할 것이므로 LocalDate로 변환 + LocalDate now = LocalDate.now(); + LocalDate startOfWeek = now.with(DayOfWeek.MONDAY); // 이번 주 월요일 + LocalDate endOfWeek = now.with(DayOfWeek.SUNDAY); // 이번 주 일요일 - // 이번 주의 첫 번째 요일과 마지막 요일 가져오기 (월요일 ~ 일요일) - LocalDate startOfWeek = now.with(DayOfWeek.MONDAY); - LocalDate endOfWeek = now.with(DayOfWeek.SUNDAY); + // 마감일의 날짜 부분을 가져옴 + LocalDate deadlineDate = deadline.toLocalDate(); // 마감일이 이번 주 내에 있는지 확인 return !deadlineDate.isBefore(startOfWeek) && !deadlineDate.isAfter(endOfWeek); From 7197c4af431cbd61d2a9c8bfa48a043c015b2d15 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Fri, 23 Aug 2024 00:49:11 +0900 Subject: [PATCH 08/14] =?UTF-8?q?feat:=20=EA=B3=BC=EC=A0=9C=20=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C=20=EB=82=B4=EC=97=AD=EC=9D=B4=20null=EC=9D=BC?= =?UTF-8?q?=EB=95=8C=20=EA=B3=A0=EB=A0=A4=ED=95=B4=EC=84=9C=20response?= =?UTF-8?q?=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/AssignmentStatusResponse.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java index d25a24cb6..d0405a2ca 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java @@ -1,5 +1,7 @@ package com.gdschongik.gdsc.domain.study.dto.response; +import static com.gdschongik.gdsc.domain.study.domain.SubmissionFailureType.NOT_SUBMITTED; + import com.gdschongik.gdsc.domain.study.domain.*; import com.gdschongik.gdsc.domain.study.domain.vo.Assignment; import io.swagger.v3.oas.annotations.media.Schema; @@ -16,11 +18,27 @@ public record AssignmentStatusResponse( @Nullable @Schema(description = "과제 명세 링크") String descriptionLink, @Nullable @Schema(description = "마감 기한") LocalDateTime deadline, @Nullable @Schema(description = "과제 제출 링크") String submissionLink, - @Nullable @Schema(description = "과제 제출 실패 사유") SubmissionFailureType submissionFailureType, + @Nullable @Schema(description = "과제 제출 실패 사유. 제출 여부도 포함되어 있습니다. 미제출 상태라면 기본 과제 정보만 반환합니다.") + SubmissionFailureType submissionFailureType, @Nullable @Schema(description = "최종 수정 일시") LocalDateTime committedAt) { public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) { StudyDetail studyDetail = assignmentHistory.getStudyDetail(); Assignment assignment = studyDetail.getAssignment(); + + if (assignmentHistory == null) { + // 과제 제출이 없는 경우, 과제 정보만 사용하여 AssignmentStatusResponse 생성 + return new AssignmentStatusResponse( + studyDetail.getId(), + assignment.getStatus(), + studyDetail.getWeek(), + assignment.getTitle(), + null, + assignment.getDescriptionLink(), + assignment.getDeadline(), + null, + NOT_SUBMITTED, + null); + } return new AssignmentStatusResponse( studyDetail.getId(), assignment.getStatus(), From 36692d43d99ba4de3af053d672fea6d60d727477 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Fri, 23 Aug 2024 19:47:30 +0900 Subject: [PATCH 09/14] =?UTF-8?q?feat:=20=EA=B3=BC=EC=A0=9C=20=EC=A0=9C?= =?UTF-8?q?=EC=B6=9C=20=EC=9D=B4=EB=A0=A5=EC=9D=B4=20=EC=97=86=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=20StudyDetail=EC=97=90=EC=84=9C=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=99=80=EC=84=9C=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudentStudyDetailService.java | 8 +++++ .../study/dao/StudyDetailRepository.java | 2 ++ .../response/AssignmentStatusResponse.java | 29 ++++++++++--------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index b9f286230..d960f6687 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -55,12 +55,20 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { @Transactional(readOnly = true) public List getUpcomingAssignments(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); + List studyDetails = studyDetailRepository.findAllByStudyId(studyId).stream() + .filter(studyDetail -> studyDetail.isAssignmentDeadlineThisWeek()) + .toList(); List assignmentHistories = assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(currentMember, studyId).stream() .filter(assignmentHistory -> assignmentHistory.getStudyDetail().isAssignmentDeadlineThisWeek()) .toList(); + if (assignmentHistories.isEmpty()) { + return studyDetails.stream() + .map(AssignmentStatusResponse::fromStudyDetail) + .toList(); + } return assignmentHistories.stream().map(AssignmentStatusResponse::from).toList(); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java index 5c4fc8c69..c3f317f54 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyDetailRepository.java @@ -7,4 +7,6 @@ public interface StudyDetailRepository extends JpaRepository { List findAllByStudyIdOrderByWeekAsc(Long studyId); + + List findAllByStudyId(Long studyId); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java index d0405a2ca..4fad36dd8 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java @@ -25,20 +25,6 @@ public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) StudyDetail studyDetail = assignmentHistory.getStudyDetail(); Assignment assignment = studyDetail.getAssignment(); - if (assignmentHistory == null) { - // 과제 제출이 없는 경우, 과제 정보만 사용하여 AssignmentStatusResponse 생성 - return new AssignmentStatusResponse( - studyDetail.getId(), - assignment.getStatus(), - studyDetail.getWeek(), - assignment.getTitle(), - null, - assignment.getDescriptionLink(), - assignment.getDeadline(), - null, - NOT_SUBMITTED, - null); - } return new AssignmentStatusResponse( studyDetail.getId(), assignment.getStatus(), @@ -51,4 +37,19 @@ public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) assignmentHistory.getSubmissionFailureType(), assignmentHistory.getCommittedAt()); } + + // 과제 제출이 없는 경우, 과제 정보만 사용하여 AssignmentStatusResponse 생성 + public static AssignmentStatusResponse fromStudyDetail(StudyDetail studyDetail) { + return new AssignmentStatusResponse( + studyDetail.getId(), + studyDetail.getAssignment().getStatus(), + studyDetail.getWeek(), + studyDetail.getAssignment().getTitle(), + null, + studyDetail.getAssignment().getDescriptionLink(), + studyDetail.getAssignment().getDeadline(), + null, + NOT_SUBMITTED, + null); + } } From f86e78804c1c0ce77f47864a18fcfed49e6e0a83 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Fri, 23 Aug 2024 19:52:21 +0900 Subject: [PATCH 10/14] =?UTF-8?q?feat:=20=EA=B3=BC=EC=A0=9C=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=ED=81=B4=EB=9E=98=EC=8A=A4=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/api/StudentStudyDetailController.java | 6 +++--- .../study/application/StudentStudyDetailService.java | 10 ++++++---- ...nse.java => AssignmentHistoryStatusResponse.java} | 12 ++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) rename src/main/java/com/gdschongik/gdsc/domain/study/dto/response/{AssignmentStatusResponse.java => AssignmentHistoryStatusResponse.java} (86%) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java index 49824c0ee..b50523ac0 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java @@ -2,7 +2,7 @@ import com.gdschongik.gdsc.domain.study.application.StudentStudyDetailService; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentDashboardResponse; -import com.gdschongik.gdsc.domain.study.dto.response.AssignmentStatusResponse; +import com.gdschongik.gdsc.domain.study.dto.response.AssignmentHistoryStatusResponse; import com.gdschongik.gdsc.domain.study.dto.response.StudyStudentSessionResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -32,9 +32,9 @@ public ResponseEntity getSubmittableAssignments( @Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.") @GetMapping("/assignments/upcoming") - public ResponseEntity> getUpcomingAssignments( + public ResponseEntity> getUpcomingAssignments( @RequestParam(name = "studyId") Long studyId) { - List response = studentStudyDetailService.getUpcomingAssignments(studyId); + List response = studentStudyDetailService.getUpcomingAssignments(studyId); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index d960f6687..0d68a4ca4 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -11,7 +11,7 @@ import com.gdschongik.gdsc.domain.study.domain.StudyDetail; import com.gdschongik.gdsc.domain.study.domain.StudyHistory; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentDashboardResponse; -import com.gdschongik.gdsc.domain.study.dto.response.AssignmentStatusResponse; +import com.gdschongik.gdsc.domain.study.dto.response.AssignmentHistoryStatusResponse; import com.gdschongik.gdsc.domain.study.dto.response.AssignmentSubmittableDto; import com.gdschongik.gdsc.domain.study.dto.response.StudyStudentSessionResponse; import com.gdschongik.gdsc.global.exception.CustomException; @@ -53,7 +53,7 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { } @Transactional(readOnly = true) - public List getUpcomingAssignments(Long studyId) { + public List getUpcomingAssignments(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); List studyDetails = studyDetailRepository.findAllByStudyId(studyId).stream() .filter(studyDetail -> studyDetail.isAssignmentDeadlineThisWeek()) @@ -66,10 +66,12 @@ public List getUpcomingAssignments(Long studyId) { if (assignmentHistories.isEmpty()) { return studyDetails.stream() - .map(AssignmentStatusResponse::fromStudyDetail) + .map(AssignmentHistoryStatusResponse::fromStudyDetail) .toList(); } - return assignmentHistories.stream().map(AssignmentStatusResponse::from).toList(); + return assignmentHistories.stream() + .map(AssignmentHistoryStatusResponse::from) + .toList(); } @Transactional(readOnly = true) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java similarity index 86% rename from src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java rename to src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java index 4fad36dd8..30eb74eae 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java @@ -8,7 +8,7 @@ import jakarta.annotation.Nullable; import java.time.LocalDateTime; -public record AssignmentStatusResponse( +public record AssignmentHistoryStatusResponse( Long studyDetailId, @Schema(description = "과제 상태") StudyStatus assignmentStatus, @Schema(description = "주차") Long week, @@ -21,11 +21,11 @@ public record AssignmentStatusResponse( @Nullable @Schema(description = "과제 제출 실패 사유. 제출 여부도 포함되어 있습니다. 미제출 상태라면 기본 과제 정보만 반환합니다.") SubmissionFailureType submissionFailureType, @Nullable @Schema(description = "최종 수정 일시") LocalDateTime committedAt) { - public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) { + public static AssignmentHistoryStatusResponse from(AssignmentHistory assignmentHistory) { StudyDetail studyDetail = assignmentHistory.getStudyDetail(); Assignment assignment = studyDetail.getAssignment(); - return new AssignmentStatusResponse( + return new AssignmentHistoryStatusResponse( studyDetail.getId(), assignment.getStatus(), studyDetail.getWeek(), @@ -38,9 +38,9 @@ public static AssignmentStatusResponse from(AssignmentHistory assignmentHistory) assignmentHistory.getCommittedAt()); } - // 과제 제출이 없는 경우, 과제 정보만 사용하여 AssignmentStatusResponse 생성 - public static AssignmentStatusResponse fromStudyDetail(StudyDetail studyDetail) { - return new AssignmentStatusResponse( + // 과제 제출이 없는 경우, 과제 정보만 사용하여 AssignmentHistoryStatusResponse 생성 + public static AssignmentHistoryStatusResponse fromStudyDetail(StudyDetail studyDetail) { + return new AssignmentHistoryStatusResponse( studyDetail.getId(), studyDetail.getAssignment().getStatus(), studyDetail.getWeek(), From d9fccc65c3f750a428bd43223adcdd8eefe60c9e Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Fri, 23 Aug 2024 23:13:10 +0900 Subject: [PATCH 11/14] =?UTF-8?q?feat:=20=EA=B3=BC=EC=A0=9C=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/application/StudentStudyDetailService.java | 1 + .../study/dto/response/AssignmentHistoryStatusResponse.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index 0d68a4ca4..1864bf2aa 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -63,6 +63,7 @@ public List getUpcomingAssignments(Long studyId .filter(assignmentHistory -> assignmentHistory.getStudyDetail().isAssignmentDeadlineThisWeek()) .toList(); + List response = studyDetails.stream().map(studyDetail -> AssignmentHistoryStatusResponse.of(studyDetail,assignmentHistories)).toList(); if (assignmentHistories.isEmpty()) { return studyDetails.stream() diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java index 30eb74eae..248dd1f55 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/AssignmentHistoryStatusResponse.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import jakarta.annotation.Nullable; import java.time.LocalDateTime; +import java.util.List; public record AssignmentHistoryStatusResponse( Long studyDetailId, From 8b09f4f1c9d5017a743705efdaa0a1f36e43fcdd Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Sat, 24 Aug 2024 00:52:18 +0900 Subject: [PATCH 12/14] =?UTF-8?q?feat:=20npe=20=EC=98=88=EB=B0=A9=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/application/StudentStudyDetailService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index 7b9492de5..5864f0cf3 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -58,7 +58,8 @@ studyDetail, getSubmittedAssignment(assignmentHistories, studyDetail))) public List getUpcomingAssignments(Long studyId) { Member currentMember = memberUtil.getCurrentMember(); List studyDetails = studyDetailRepository.findAllByStudyId(studyId).stream() - .filter(studyDetail -> studyDetail.isAssignmentDeadlineThisWeek()) + .filter(studyDetail -> + studyDetail.getAssignment().isOpen() && studyDetail.isAssignmentDeadlineThisWeek()) .toList(); List assignmentHistories = assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(currentMember, studyId).stream() From 0ca5d970b21871202fe4ee66332fb60dd791955d Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Sat, 24 Aug 2024 18:09:35 +0900 Subject: [PATCH 13/14] =?UTF-8?q?fix:=20=EB=A8=B8=EC=A7=80=20=EC=BB=A8?= =?UTF-8?q?=ED=94=8C=EB=A6=AD=ED=8A=B8=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/StudentStudyDetailController.java | 16 ++++---- .../StudentStudyDetailService.java | 38 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java index b50523ac0..023ee2d41 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyDetailController.java @@ -30,14 +30,6 @@ public ResponseEntity getSubmittableAssignments( return ResponseEntity.ok(response); } - @Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.") - @GetMapping("/assignments/upcoming") - public ResponseEntity> getUpcomingAssignments( - @RequestParam(name = "studyId") Long studyId) { - List response = studentStudyDetailService.getUpcomingAssignments(studyId); - return ResponseEntity.ok(response); - } - // TODO 스터디 세션 워딩을 커리큘럼으로 변경해야함 @Operation(summary = "스터디 커리큘럼 조회", description = "해당 스터디의 커리큘럼들을 조회합니다.") @GetMapping("/sessions") @@ -46,4 +38,12 @@ public ResponseEntity> getStudySessions( List response = studentStudyDetailService.getStudySessions(studyId); return ResponseEntity.ok(response); } + + @Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.") + @GetMapping("/assignments/upcoming") + public ResponseEntity> getUpcomingAssignments( + @RequestParam(name = "studyId") Long studyId) { + List response = studentStudyDetailService.getUpcomingAssignments(studyId); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index 5864f0cf3..ef27dd5c8 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -54,25 +54,6 @@ studyDetail, getSubmittedAssignment(assignmentHistories, studyDetail))) return AssignmentDashboardResponse.of(studyHistory.getRepositoryLink(), isAnySubmitted, submittableAssignments); } - @Transactional(readOnly = true) - public List getUpcomingAssignments(Long studyId) { - Member currentMember = memberUtil.getCurrentMember(); - List studyDetails = studyDetailRepository.findAllByStudyId(studyId).stream() - .filter(studyDetail -> - studyDetail.getAssignment().isOpen() && studyDetail.isAssignmentDeadlineThisWeek()) - .toList(); - List assignmentHistories = - assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(currentMember, studyId).stream() - .filter(assignmentHistory -> - assignmentHistory.getStudyDetail().isAssignmentDeadlineThisWeek()) - .toList(); - - return studyDetails.stream() - .map(studyDetail -> AssignmentHistoryStatusResponse.of( - studyDetail, getSubmittedAssignment(assignmentHistories, studyDetail))) - .toList(); - } - @Transactional(readOnly = true) public List getStudySessions(Long studyId) { Member member = memberUtil.getCurrentMember(); @@ -103,4 +84,23 @@ private boolean isAttended(List attendances, StudyDetail studyDetail return attendances.stream() .anyMatch(attendance -> attendance.getStudyDetail().getId().equals(studyDetail.getId())); } + + @Transactional(readOnly = true) + public List getUpcomingAssignments(Long studyId) { + Member currentMember = memberUtil.getCurrentMember(); + List studyDetails = studyDetailRepository.findAllByStudyId(studyId).stream() + .filter(studyDetail -> + studyDetail.getAssignment().isOpen() && studyDetail.isAssignmentDeadlineThisWeek()) + .toList(); + List assignmentHistories = + assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(currentMember, studyId).stream() + .filter(assignmentHistory -> + assignmentHistory.getStudyDetail().isAssignmentDeadlineThisWeek()) + .toList(); + + return studyDetails.stream() + .map(studyDetail -> AssignmentHistoryStatusResponse.of( + studyDetail, getSubmittedAssignment(assignmentHistories, studyDetail))) + .toList(); + } } From dc9d745f1a1751eb1f772d2c1e86e165f80ac1b6 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Sat, 24 Aug 2024 18:14:22 +0900 Subject: [PATCH 14/14] feat: merge develop --- .../domain/study/application/StudentStudyDetailService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java index c8ee2953b..046a1204d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyDetailService.java @@ -62,7 +62,7 @@ public List getStudyTodoList(Long studyId) { Member member = memberUtil.getCurrentMember(); final List studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId); final List assignmentHistories = - assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudy(member, studyId); + assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(member, studyId); final List attendances = attendanceRepository.findByMemberAndStudyId(member, studyId); LocalDate now = LocalDate.now();