-
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.
Browse files
Browse the repository at this point in the history
* refactor: createCurriculumItemAndAssignToParticipant 메서드 리팩토링 * refactor: checkCurriculumItem 관련 리팩토링 * refactor: 권한 체크 구문은 별도의 클래스로 빠져나오도록 수정 * refactor : member관련 권한 class 수정 * refactor: 스터디 관련 권한 별도 class 수정 * refactor: 팀 관련 권한 체크 별도 class 구분 * refactor: findAll.size에서 count로 변경 * fix: studyRole 및 teamRole이 존재하는지 확인하는 로직으로 변경 - 더이상 역할 추가가 없을 예정으로 해당 방식으로 변경하였음 * chore: 적절한 파라미터명으로 변경 * fix: teamRole 관련 메서드 통일 * Merge branch 'develop' into Feature/#179-커리큘럼_파트의_메서드를_짧게_수정한다 # Conflicts: # src/main/java/doore/study/application/ParticipantQueryService.java
- Loading branch information
Showing
11 changed files
with
152 additions
and
140 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
Oops, something went wrong.