From 171694cc3d4e4f5d762b19434ce0c186492251ba Mon Sep 17 00:00:00 2001 From: Cho Sangwook <82208159+Sangwook02@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:14:01 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A0=88=ED=8F=AC=EC=A7=80=ED=86=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=9E=85=EB=A0=A5=20API=20path=20variable=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#735)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 레포지토리 입력 api path variable 수정 --- .../domain/study/api/StudentStudyHistoryController.java | 6 +++--- .../study/application/StudentStudyHistoryService.java | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) 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);