-
Notifications
You must be signed in to change notification settings - Fork 8
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
[BE] 수정 시, 현재 인원 초기화 + 방 삭제 / 수정 시 오픈 상태일때만 수정하게 변경(#637) #639
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
27f2933
refactor: 리뷰 클라이언트 패키지 이동 및 리팩토링
youngsu5582 e340649
refactor: 리뷰 서비스 리팩토링
youngsu5582 c9993d2
fix: 충돌 해결
youngsu5582 7243020
chore: ExceptionType 명확하게 변경
youngsu5582 9de6817
fix: 잘못된 매개변수 변경
youngsu5582 30ed363
refactor: reader,writer 통해 기능 분리
youngsu5582 81cdd29
Merge branch 'develop' into feat/#637
youngsu5582 87a7ff0
refactor:피드백 반영
youngsu5582 06976c7
test: 테스트 예제 추가
youngsu5582 99d72f7
fix: 방 상태를 그대로 가지게 변경
youngsu5582 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
21 changes: 21 additions & 0 deletions
21
backend/src/main/java/corea/member/domain/MemberReader.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,21 @@ | ||
package corea.member.domain; | ||
|
||
import corea.exception.CoreaException; | ||
import corea.exception.ExceptionType; | ||
import corea.member.repository.MemberRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class MemberReader { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
public Member findOne(long memberId) { | ||
return memberRepository.findById(memberId) | ||
.orElseThrow(() -> new CoreaException(ExceptionType.MEMBER_NOT_FOUND)); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
backend/src/main/java/corea/participation/domain/ParticipationReader.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,19 @@ | ||
package corea.participation.domain; | ||
|
||
import corea.member.domain.MemberRole; | ||
import corea.participation.repository.ParticipationRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ParticipationReader { | ||
|
||
private final ParticipationRepository participationRepository; | ||
|
||
public MemberRole findMemberRole(long roomId, long memberId) { | ||
return participationRepository.findByRoomIdAndMemberId(roomId, memberId) | ||
.map(Participation::getMemberRole) | ||
.orElse(MemberRole.NONE); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package corea.room.domain; | ||
|
||
import corea.exception.CoreaException; | ||
import corea.exception.ExceptionType; | ||
import corea.member.domain.Member; | ||
import corea.participation.domain.ParticipationWriter; | ||
import corea.room.dto.RoomCreateRequest; | ||
import corea.room.dto.RoomUpdateRequest; | ||
import corea.room.repository.RoomRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class RoomWriter { | ||
|
||
private static final int PLUS_HOURS_TO_MINIMUM_RECRUITMENT_DEADLINE = 1; | ||
private static final int PLUS_DAYS_TO_MINIMUM_REVIEW_DEADLINE = 1; | ||
|
||
private final RoomRepository roomRepository; | ||
private final ParticipationWriter participationWriter; | ||
|
||
public Room create(Member member, RoomCreateRequest request) { | ||
// validateDeadLine(request.recruitmentDeadline(), request.reviewDeadline()); | ||
Room room = roomRepository.save(request.toEntity(member)); | ||
log.info("방을 생성했습니다. 방 생성자 id={}, 요청한 사용자 id={}", room.getId(), room.getManagerId()); | ||
return room; | ||
} | ||
|
||
public Room update(Room room, Member member, RoomUpdateRequest request) { | ||
validate(room, member); | ||
return roomRepository.save(request.toEntity(room, member)); | ||
} | ||
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. Controller 단에서 전달받은 dto를 그대로 전달받았는데, 이 부분 급하다고 하니 TODO로 남기고 넘어가보시죠!~ |
||
|
||
public void delete(Room room, Member member) { | ||
validate(room, member); | ||
roomRepository.delete(room); | ||
participationWriter.deleteAllByRoom(room); | ||
log.info("방을 삭제했습니다. 방 id={}, 사용자 iD={}", room.getId(), member.getId()); | ||
} | ||
|
||
private void validate(Room room, Member member) { | ||
if (room.isNotMatchingManager(member.getId())) { | ||
log.warn("인증되지 않은 방 변경 시도 방 생성자 id={}, 요청한 사용자 id={}", room.getId(), member.getId()); | ||
throw new CoreaException(ExceptionType.ROOM_MODIFY_AUTHORIZATION_ERROR); | ||
} | ||
if (room.isNotOpened()) { | ||
throw new CoreaException(ExceptionType.ROOM_STATUS_INVALID); | ||
} | ||
} | ||
|
||
// private void validateDeadLine(LocalDateTime recruitmentDeadline, LocalDateTime reviewDeadline) { | ||
// LocalDateTime currentDateTime = LocalDateTime.now(); | ||
// | ||
// LocalDateTime minimumRecruitmentDeadline = currentDateTime.plusHours(PLUS_HOURS_TO_MINIMUM_RECRUITMENT_DEADLINE); | ||
// if (recruitmentDeadline.isBefore(minimumRecruitmentDeadline)) { | ||
// throw new CoreaException(ExceptionType.INVALID_RECRUITMENT_DEADLINE, | ||
// String.format("모집 마감 시간은 현재 시간보다 %d시간 이후여야 합니다.", PLUS_HOURS_TO_MINIMUM_RECRUITMENT_DEADLINE)); | ||
// } | ||
// LocalDateTime minimumReviewDeadline = recruitmentDeadline.plusDays(PLUS_DAYS_TO_MINIMUM_REVIEW_DEADLINE); | ||
// if (reviewDeadline.isBefore(minimumReviewDeadline)) { | ||
// throw new CoreaException(ExceptionType.INVALID_REVIEW_DEADLINE, | ||
// String.format("리뷰 마감 시간은 모집 마감 시간보다 %d일 이후여야 합니다.", PLUS_DAYS_TO_MINIMUM_REVIEW_DEADLINE)); | ||
// } | ||
// } | ||
} |
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.
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.
마찬가지로
create
,update
,delete
모두member
->manager
로 변경되어도 좋을 것 같습니다~