Skip to content

Commit

Permalink
보드게임 완료 로직
Browse files Browse the repository at this point in the history
  • Loading branch information
enbraining committed Dec 31, 2023
1 parent 11b0833 commit 53117c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

Expand All @@ -12,4 +13,5 @@ public interface BoardgameRepository extends JpaRepository<Boardgame, Long> {

Optional<Boardgame> findBoardgameById(UUID id);

void deleteById(UUID id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ public void joinBoardgame(UUID id) {
}

@Override
@Transactional
public void doneBoardgame(UUID boardgameId) {
UUID memberId = UUID.fromString(SecurityContextHolder.getContext().getAuthentication().getName());
Boardgame boardgame = boardgameRepository.findBoardgameById(boardgameId).orElseThrow(BoardgameNotFoundException::new);
Member member = memberRepository.findMemberById(memberId).orElseThrow(MemberNotFoundException::new);
member.removeBoardgame(boardgame);

boardgameRepository.delete(boardgame);
member.removeBoardgame(boardgameRepository.findBoardgameById(boardgameId).get());
memberRepository.save(member);

boardgameRepository.deleteById(boardgameId);
}
}

0 comments on commit 53117c3

Please sign in to comment.