-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 이번주 과제 조회 API 구현 #647
Changes from 15 commits
21dcdd7
dc17536
f1d9c91
0fe4c06
ed8f8d1
6513447
15c5bb7
1b29a9a
1c614a8
c71c2ff
7197c4a
36692d4
f86e788
d9fccc6
497038a
8b09f4f
0ca5d97
1a50295
dc9d745
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 |
---|---|---|
|
@@ -10,6 +10,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.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; | ||
|
@@ -38,7 +39,7 @@ public AssignmentDashboardResponse getSubmittableAssignments(Long studyId) { | |
.findByStudentAndStudyId(currentMember, studyId) | ||
.orElseThrow(() -> new CustomException(ErrorCode.STUDY_HISTORY_NOT_FOUND)); | ||
List<AssignmentHistory> assignmentHistories = | ||
assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudy(currentMember, studyId); | ||
assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(currentMember, studyId); | ||
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId).stream() | ||
.filter(studyDetail -> | ||
studyDetail.getAssignment().isOpen() && studyDetail.isAssignmentDeadlineRemaining()) | ||
|
@@ -53,12 +54,30 @@ studyDetail, getSubmittedAssignment(assignmentHistories, studyDetail))) | |
return AssignmentDashboardResponse.of(studyHistory.getRepositoryLink(), isAnySubmitted, submittableAssignments); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<AssignmentHistoryStatusResponse> getUpcomingAssignments(Long studyId) { | ||
Member currentMember = memberUtil.getCurrentMember(); | ||
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyId(studyId).stream() | ||
.filter(studyDetail -> studyDetail.isAssignmentDeadlineThisWeek()) | ||
.toList(); | ||
List<AssignmentHistory> assignmentHistories = | ||
assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(currentMember, studyId).stream() | ||
.filter(assignmentHistory -> | ||
assignmentHistory.getStudyDetail().isAssignmentDeadlineThisWeek()) | ||
.toList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제출한 이력이 없는 과제에 대해서는 AssignmentHistory가 존재하지 않습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Response한번 보시겠어요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이해했습니다~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이해했어용 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 근데 질문이 있는데 수강신청하면 자동으로 저 assignmentHistory가 생기는게 아닌가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StudentStudyHistoryService의 findOrCreate 메서드 확인해주세요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그런데 상욱님 제가 만든 Response를 보시면 null이면 Assignment를 반환하게 만들었는데 이걸로 충분한거 같은데 왜 다른 로직이 필요하다고 생각하신지 여쭈어봐도 될까용 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어 아니에요!! 무시하셔두 됩니다 제가 오늘 밤에 퇴근하고 고칠게요 |
||
|
||
return studyDetails.stream() | ||
.map(studyDetail -> AssignmentHistoryStatusResponse.of( | ||
studyDetail, getSubmittedAssignment(assignmentHistories, studyDetail))) | ||
.toList(); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<StudyStudentSessionResponse> getStudySessions(Long studyId) { | ||
Member member = memberUtil.getCurrentMember(); | ||
final List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId); | ||
final List<AssignmentHistory> assignmentHistories = | ||
assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudy(member, studyId); | ||
assignmentHistoryRepository.findAssignmentHistoriesByStudentAndStudyId(member, studyId); | ||
final List<Attendance> attendances = attendanceRepository.findByMemberAndStudyId(member, studyId); | ||
|
||
return studyDetails.stream() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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; | ||
import jakarta.annotation.Nullable; | ||
import java.time.LocalDateTime; | ||
|
||
public record AssignmentHistoryStatusResponse( | ||
Long studyDetailId, | ||
@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, | ||
@Nullable @Schema(description = "과제 제출 링크") String submissionLink, | ||
@Nullable @Schema(description = "과제 제출 실패 사유. 제출 여부도 포함되어 있습니다. 미제출 상태라면 기본 과제 정보만 반환합니다.") | ||
SubmissionFailureType submissionFailureType, | ||
@Nullable @Schema(description = "최종 수정 일시") LocalDateTime committedAt) { | ||
Comment on lines
+11
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필드 정의가 잘 되어 있습니다. 필드에 대한 API 문서화가 적절하게 이루어졌습니다. TODO 주석은 추후 작업을 나타냅니다. 추후 작업에 대한 도움이 필요하시면 말씀해 주세요. 관련 GitHub 이슈를 생성할 수 있습니다. |
||
|
||
// 과제 제출이 없는 경우, 과제 정보만 사용하여 AssignmentHistoryStatusResponse 생성 | ||
public static AssignmentHistoryStatusResponse of(StudyDetail studyDetail, AssignmentHistory assignmentHistory) { | ||
if (assignmentHistory == null) { | ||
return new AssignmentHistoryStatusResponse( | ||
studyDetail.getId(), | ||
studyDetail.getAssignment().getStatus(), | ||
studyDetail.getWeek(), | ||
studyDetail.getAssignment().getTitle(), | ||
null, | ||
studyDetail.getAssignment().getDescriptionLink(), | ||
studyDetail.getAssignment().getDeadline(), | ||
null, | ||
NOT_SUBMITTED, | ||
null); | ||
} | ||
|
||
Assignment assignment = studyDetail.getAssignment(); | ||
return new AssignmentHistoryStatusResponse( | ||
studyDetail.getId(), | ||
assignment.getStatus(), | ||
studyDetail.getWeek(), | ||
assignment.getTitle(), | ||
assignmentHistory.getSubmissionStatus(), | ||
assignment.getDescriptionLink(), | ||
assignment.getDeadline(), | ||
assignmentHistory.getSubmissionLink(), | ||
assignmentHistory.getSubmissionFailureType(), | ||
assignmentHistory.getCommittedAt()); | ||
} | ||
} |
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.
이거 아마 한번 돌려보시면 assignment.deadline이 null인 경우에 익셉션 던져질거에요!
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.
위에 구현하신 isOpen가져와서 비교하는 대로 수정했습니다