diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java index 48faedcdf..8764e5a95 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyHistoryController.java @@ -21,10 +21,10 @@ public class StudentStudyHistoryController { private final StudentStudyHistoryService studentStudyHistoryService; @Operation(summary = "레포지토리 입력", description = "레포지토리를 입력합니다. 이미 제출한 과제가 있다면 수정할 수 없습니다.") - @PutMapping("/{studyHistoryId}/repository") + @PutMapping("/{studyId}/repository") public ResponseEntity updateRepository( - @PathVariable Long studyHistoryId, @Valid @RequestBody RepositoryUpdateRequest request) throws IOException { - studentStudyHistoryService.updateRepository(studyHistoryId, request); + @PathVariable Long studyId, @Valid @RequestBody RepositoryUpdateRequest request) throws IOException { + studentStudyHistoryService.updateRepository(studyId, request); return ResponseEntity.ok().build(); } 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 8a1eb7b42..17da03cf1 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 @@ -7,6 +7,7 @@ import com.gdschongik.gdsc.domain.study.dao.AssignmentHistoryRepository; import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository; import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyRepository; import com.gdschongik.gdsc.domain.study.domain.AssignmentHistory; import com.gdschongik.gdsc.domain.study.domain.AssignmentHistoryGrader; import com.gdschongik.gdsc.domain.study.domain.AssignmentSubmissionFetcher; @@ -43,14 +44,15 @@ public class StudentStudyHistoryService { private final StudyHistoryValidator studyHistoryValidator; private final StudyAssignmentHistoryValidator studyAssignmentHistoryValidator; private final AssignmentHistoryGrader assignmentHistoryGrader; + private final StudyRepository studyRepository; @Transactional - public void updateRepository(Long studyHistoryId, RepositoryUpdateRequest request) throws IOException { + public void updateRepository(Long studyId, RepositoryUpdateRequest request) throws IOException { Member currentMember = memberUtil.getCurrentMember(); + Study study = studyRepository.findById(studyId).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND)); StudyHistory studyHistory = studyHistoryRepository - .findById(studyHistoryId) + .findByStudentAndStudy(currentMember, study) .orElseThrow(() -> new CustomException(STUDY_HISTORY_NOT_FOUND)); - Study study = studyHistory.getStudy(); boolean isAnyAssignmentSubmitted = assignmentHistoryRepository.existsSubmittedAssignmentByMemberAndStudy(currentMember, study); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyCurriculumResponse.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyCurriculumResponse.java index 6771a2017..12f73f55b 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyCurriculumResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyCurriculumResponse.java @@ -3,10 +3,17 @@ import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period; import com.gdschongik.gdsc.domain.study.domain.Difficulty; import com.gdschongik.gdsc.domain.study.domain.StudyDetail; +import com.gdschongik.gdsc.domain.study.domain.StudyStatus; import com.gdschongik.gdsc.domain.study.domain.vo.Curriculum; public record StudyCurriculumResponse( - Long studyDetailId, Period period, Long week, String title, String description, Difficulty difficulty) { + Long studyDetailId, + Period period, + Long week, + String title, + String description, + Difficulty difficulty, + StudyStatus curriculumStatus) { public static StudyCurriculumResponse from(StudyDetail studyDetail) { Curriculum curriculum = studyDetail.getCurriculum(); @@ -16,6 +23,7 @@ public static StudyCurriculumResponse from(StudyDetail studyDetail) { studyDetail.getWeek(), curriculum.getTitle(), curriculum.getDescription(), - curriculum.getDifficulty()); + curriculum.getDifficulty(), + curriculum.getStatus()); } }