-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/BDD-CLUB/01-doo-re-back …
…into develop
- Loading branch information
Showing
17 changed files
with
283 additions
and
214 deletions.
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
32 changes: 32 additions & 0 deletions
32
src/main/java/doore/member/application/convenience/StudyRoleValidateAccessPermission.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,32 @@ | ||
package doore.member.application.convenience; | ||
|
||
import static doore.member.domain.StudyRoleType.ROLE_스터디장; | ||
import static doore.member.exception.MemberExceptionType.NOT_FOUND_MEMBER_ROLE_IN_STUDY; | ||
import static doore.member.exception.MemberExceptionType.UNAUTHORIZED; | ||
|
||
import doore.member.domain.StudyRole; | ||
import doore.member.domain.repository.StudyRoleRepository; | ||
import doore.member.exception.MemberException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class StudyRoleValidateAccessPermission { | ||
private final StudyRoleRepository studyRoleRepository; | ||
|
||
public void validateExistStudyLeader(final Long studyId, final Long memberId) { | ||
final StudyRole studyRole = studyRoleRepository.findStudyRoleByStudyIdAndMemberId(studyId, memberId) | ||
.orElseThrow(() -> new MemberException(NOT_FOUND_MEMBER_ROLE_IN_STUDY)); | ||
if (!studyRole.getStudyRoleType().equals(ROLE_스터디장)) { | ||
throw new MemberException(UNAUTHORIZED); | ||
} | ||
} | ||
|
||
public void validateExistParticipant(final Long studyId, final Long memberId) { | ||
studyRoleRepository.findStudyRoleByStudyIdAndMemberId(studyId, memberId) | ||
.orElseThrow(() -> new MemberException(UNAUTHORIZED)); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/doore/member/application/convenience/TeamRoleValidateAccessPermission.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,32 @@ | ||
package doore.member.application.convenience; | ||
|
||
import static doore.member.domain.TeamRoleType.ROLE_팀장; | ||
import static doore.member.exception.MemberExceptionType.NOT_FOUND_MEMBER_ROLE_IN_TEAM; | ||
import static doore.member.exception.MemberExceptionType.UNAUTHORIZED; | ||
|
||
import doore.member.domain.TeamRole; | ||
import doore.member.domain.repository.TeamRoleRepository; | ||
import doore.member.exception.MemberException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class TeamRoleValidateAccessPermission { | ||
private final TeamRoleRepository teamRoleRepository; | ||
|
||
public void validateExistTeamLeader(final Long teamId, final Long memberId) { | ||
final TeamRole teamRole = teamRoleRepository.findTeamRoleByTeamIdAndMemberId(teamId, memberId) | ||
.orElseThrow(() -> new MemberException(NOT_FOUND_MEMBER_ROLE_IN_TEAM)); | ||
if (!teamRole.getTeamRoleType().equals(ROLE_팀장)) { | ||
throw new MemberException(UNAUTHORIZED); | ||
} | ||
} | ||
|
||
public void validateExistMemberTeam(final Long teamId, final Long memberId) { | ||
teamRoleRepository.findTeamRoleByTeamIdAndMemberId(teamId, memberId) | ||
.orElseThrow(() -> new MemberException(UNAUTHORIZED)); | ||
} | ||
} |
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
Oops, something went wrong.