-
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 추가 #644
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import com.gdschongik.gdsc.domain.member.domain.Member; | ||
import com.gdschongik.gdsc.global.annotation.DomainService; | ||
import com.gdschongik.gdsc.global.exception.CustomException; | ||
import java.util.Optional; | ||
|
||
@DomainService | ||
public class StudyValidator { | ||
|
@@ -14,7 +15,7 @@ public void validateStudyMentor(Member currentMember, Study study) { | |
return; | ||
} | ||
|
||
// 어드민이 아니고 멘토 역할도 아니면 예외가 밸생합니다. | ||
// 멘토인지 검증 | ||
if (!currentMember.isMentor()) { | ||
throw new CustomException(STUDY_ACCESS_NOT_ALLOWED); | ||
} | ||
|
@@ -24,4 +25,21 @@ public void validateStudyMentor(Member currentMember, Study study) { | |
throw new CustomException(STUDY_MENTOR_INVALID); | ||
} | ||
} | ||
|
||
public void validateStudyMentorOrStudent(Member currentMember, Study study, Optional<StudyHistory> studyHistory) { | ||
// 어드민인 경우 검증 통과 | ||
if (currentMember.isAdmin()) { | ||
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. 음 근데 아예 호출하면 에러터지니 따로 private 메소드로 빼서 사용하도록할게여 |
||
return; | ||
} | ||
|
||
// 해당 스터디의 수강생인지 검증 | ||
if (currentMember.isStudent() && studyHistory.isEmpty()) { | ||
throw new CustomException(STUDY_ACCESS_NOT_ALLOWED); | ||
} | ||
|
||
// 해당 스터디의 담당 멘토인지 검증 | ||
if (!currentMember.getId().equals(study.getMentor().getId())) { | ||
throw new CustomException(STUDY_MENTOR_INVALID); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyAnnouncementResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.gdschongik.gdsc.domain.study.dto.response; | ||
|
||
import com.gdschongik.gdsc.domain.study.domain.StudyAnnouncement; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.time.LocalDate; | ||
|
||
public record StudyAnnouncementResponse( | ||
Long studyAnnounceId, | ||
@Schema(description = "제목") String title, | ||
@Schema(description = "링크") String link, | ||
@Schema(description = "생성 일자") LocalDate createdDate) { | ||
|
||
public static StudyAnnouncementResponse from(StudyAnnouncement studyAnnouncement) { | ||
return new StudyAnnouncementResponse( | ||
studyAnnouncement.getId(), | ||
studyAnnouncement.getTitle(), | ||
studyAnnouncement.getLink(), | ||
studyAnnouncement.getCreatedAt().toLocalDate()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
음 공지목록 조회는 굳이 권한 검증이 필요한가... 싶은데
이미 구현을 해두셔서 제거하기엔 좀 그렇고... 한번 보시고 제거 검토해보시면 좋을듯 합니다