From 17602711bb2125656971354d8fc99c28b467c494 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Sat, 9 Mar 2024 17:03:25 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20participant=20count=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80=20(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/doorip/trip/repository/ParticipantRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doorip-domain/src/main/java/org/doorip/trip/repository/ParticipantRepository.java b/doorip-domain/src/main/java/org/doorip/trip/repository/ParticipantRepository.java index b6b857a..39f6d76 100644 --- a/doorip-domain/src/main/java/org/doorip/trip/repository/ParticipantRepository.java +++ b/doorip-domain/src/main/java/org/doorip/trip/repository/ParticipantRepository.java @@ -11,4 +11,6 @@ public interface ParticipantRepository extends JpaRepository boolean existsByUserAndTrip(User user, Trip trip); Optional findByUserAndTrip(User user, Trip trip); + + int countByTrip(Trip trip); } From d061f22689afa57d218554009434ed3ee1b30d16 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Sat, 9 Mar 2024 17:03:53 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20my=20todo=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=BF=BC=EB=A6=AC=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/doorip/trip/repository/TodoRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doorip-domain/src/main/java/org/doorip/trip/repository/TodoRepository.java b/doorip-domain/src/main/java/org/doorip/trip/repository/TodoRepository.java index dc16927..44ed47c 100644 --- a/doorip-domain/src/main/java/org/doorip/trip/repository/TodoRepository.java +++ b/doorip-domain/src/main/java/org/doorip/trip/repository/TodoRepository.java @@ -25,8 +25,10 @@ public interface TodoRepository extends JpaRepository { "from Todo d " + "join Trip i " + "on d.trip = i " + + "join Allocator a " + + "on a.todo = d " + "join Participant p " + - "on p.trip = i " + + "on a.participant = p " + "join User u " + "on p.user = u " + "where i.id = :tripId " + From fd7a21badd58ed077aa62e4c6e1b9172e25c8fdf Mon Sep 17 00:00:00 2001 From: sunwoong Date: Sat, 9 Mar 2024 17:05:42 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20delete=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?=EB=B0=9C=EC=83=9D=20x=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/doorip/trip/service/TripDetailService.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/doorip-api/src/main/java/org/doorip/trip/service/TripDetailService.java b/doorip-api/src/main/java/org/doorip/trip/service/TripDetailService.java index 375a64e..9645741 100644 --- a/doorip-api/src/main/java/org/doorip/trip/service/TripDetailService.java +++ b/doorip-api/src/main/java/org/doorip/trip/service/TripDetailService.java @@ -68,7 +68,7 @@ public TripParticipantGetResponse getParticipants(Long userId, Long tripId) { public void leaveTrip(Long userId, Long tripId) { User findUser = getUser(userId); Trip findTrip = getTrip(tripId); - int size = calculateParticipantsCount(findTrip); + int size = participantRepository.countByTrip(findTrip); Participant findParticipant = getParticipant(findUser, findTrip); List todos = todoRepository.findMyTodoByTripIdAndUserIdAndSecret(tripId, userId, Secret.MY); todoRepository.deleteAll(todos); @@ -130,10 +130,6 @@ private User getUser(Long userId) { .orElseThrow(() -> new EntityNotFoundException(ErrorMessage.USER_NOT_FOUND)); } - private int calculateParticipantsCount(Trip findTrip) { - return findTrip.getParticipants().size(); - } - private Participant getParticipant(User findUser, Trip findTrip) { return participantRepository.findByUserAndTrip(findUser, findTrip) .orElseThrow(() -> new EntityNotFoundException(ErrorMessage.PARTICIPANT_NOT_FOUND)); @@ -166,8 +162,7 @@ private boolean isEqualUserAndParticipantUser(User user, User participantUser) { private int getValidatedResult(User user) { if (user.getResult() == null) { return -1; - } - else { + } else { return user.getResult().getNumResult(); } }