From 55f4ce6edad0ecf3b52309c8868af58eef984099 Mon Sep 17 00:00:00 2001 From: Hanbee Lee Date: Thu, 15 Aug 2024 02:17:24 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=96=B4=EB=93=9C=EB=AF=BC,=20?= =?UTF-8?q?=EB=A9=98=ED=86=A0,=20=EC=A6=89=20=EA=B2=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=9D=B8=20=ED=9A=8C=EC=9B=90=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EC=A0=91=EA=B7=BC=EC=9D=84=20=EA=B2=80=EC=A6=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/study/application/MentorStudyService.java | 3 +-- .../gdsc/domain/study/domain/StudyValidator.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyService.java index 3edd8d63b..cdc673c4e 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyService.java @@ -38,8 +38,7 @@ public List getStudyStudents(Long studyId) { Study study = studyRepository.findById(studyId).orElseThrow(() -> new CustomException(ErrorCode.STUDY_NOT_FOUND)); - studyValidator.validateStudyMentor( - currentMember.getId(), study.getMentor().getId()); + studyValidator.validateStudyMentor(currentMember, study.getMentor().getId()); List studyHistories = studyHistoryRepository.findByStudyId(studyId); return studyHistories.stream().map(StudyStudentResponse::from).toList(); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyValidator.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyValidator.java index 5351ebda3..dea0f3911 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyValidator.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyValidator.java @@ -1,14 +1,20 @@ package com.gdschongik.gdsc.domain.study.domain; import static com.gdschongik.gdsc.global.exception.ErrorCode.STUDY_MENTOR_INVALID; +import static com.gdschongik.gdsc.global.exception.ErrorCode.STUDY_MENTOR_IS_UNAUTHORIZED; +import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.global.annotation.DomainService; import com.gdschongik.gdsc.global.exception.CustomException; @DomainService public class StudyValidator { - public void validateStudyMentor(Long currentMemberId, Long mentorId) { - if (!currentMemberId.equals(mentorId)) { + public void validateStudyMentor(Member currentMember, Long mentorId) { + if (currentMember.isGuest()) { + throw new CustomException(STUDY_MENTOR_IS_UNAUTHORIZED); + } + + if (!currentMember.getId().equals(mentorId)) { throw new CustomException(STUDY_MENTOR_INVALID); } }