Skip to content

Commit

Permalink
[BE] memberId가 이미 있지만 다른 스터디를 참여할 때 null이 아닌 404내려주는 문제 (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
aak2075 authored Aug 4, 2023
1 parent 8620542 commit c58ee6a
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import harustudy.backend.common.EntityNotFoundException.RoomNotFound;
import harustudy.backend.member.domain.Member;
import harustudy.backend.member.dto.NicknameResponse;
import harustudy.backend.member.exception.MemberNotParticipatedException;
import harustudy.backend.member.repository.MemberRepository;
import harustudy.backend.progress.repository.PomodoroProgressRepository;
import harustudy.backend.room.domain.PomodoroRoom;
import harustudy.backend.room.repository.PomodoroRoomRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -21,17 +19,16 @@ public class MemberService {

private final PomodoroRoomRepository pomodoroRoomRepository;
private final MemberRepository memberRepository;
private final PomodoroProgressRepository pomodoroProgressRepository;

public NicknameResponse findParticipatedMemberNickname(Long roomId, Long memberId) {
PomodoroRoom pomodoroRoom = pomodoroRoomRepository.findById(roomId)
.orElseThrow(RoomNotFound::new);
Member member = memberRepository.findById(memberId)
.orElseThrow(MemberNotFound::new);

pomodoroProgressRepository.findByPomodoroRoomAndMember(pomodoroRoom, member)
.orElseThrow(MemberNotParticipatedException::new);

return new NicknameResponse(member.getNickname());
if (pomodoroRoom.isParticipatedMember(member)) {
return new NicknameResponse(member.getNickname());
}
return new NicknameResponse(null);
}
}

0 comments on commit c58ee6a

Please sign in to comment.