From 73c36c19d5bf4e369468d7b53f399da8bcefb228 Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Fri, 19 Jul 2024 17:15:46 +0900 Subject: [PATCH 1/2] [fix] #81 add optional RequestParam to exclude Authenticated User from member list --- .../org/kkumulkkum/server/controller/MeetingController.java | 6 ++++-- .../kkumulkkum/server/service/meeting/MeetingService.java | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kkumulkkum/server/controller/MeetingController.java b/src/main/java/org/kkumulkkum/server/controller/MeetingController.java index 05048d9..9aecdf3 100644 --- a/src/main/java/org/kkumulkkum/server/controller/MeetingController.java +++ b/src/main/java/org/kkumulkkum/server/controller/MeetingController.java @@ -63,9 +63,11 @@ public ResponseEntity getMeeting( @IsMemberByMeetingId(meetingIdParamIndex = 0) @GetMapping("/v1/meetings/{meetingId}/members") public ResponseEntity getMembers( - @PathVariable final Long meetingId + @PathVariable final Long meetingId, + @RequestParam(name = "exclude", required = false) final String exclude, + @UserId final Long userId ) { - return ResponseEntity.ok(meetingService.getMembers(meetingId)); + return ResponseEntity.ok(meetingService.getMembers(meetingId, exclude, userId)); } } diff --git a/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java b/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java index 213be93..9c57a25 100644 --- a/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java +++ b/src/main/java/org/kkumulkkum/server/service/meeting/MeetingService.java @@ -85,8 +85,12 @@ public MeetingDto getMeeting(final Long meetingId) { } @Transactional(readOnly = true) - public MembersDto getMembers(final Long meetingId) { + public MembersDto getMembers(final Long meetingId, final String exclude, final Long userId) { List members = memberRetreiver.findAllByMeetingId(meetingId); + if (exclude != null) { + Member authenticatedMember = memberRetreiver.findByMeetingIdAndUserId(meetingId, userId); + members.removeIf(member -> member.memberId().equals(authenticatedMember.getId())); + } return MembersDto.from(members); } From 4889d40809a2254db9b4177e3653357bafd2d96b Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Fri, 19 Jul 2024 17:16:48 +0900 Subject: [PATCH 2/2] [fix] #81 add Unique Constraint to avoid participant duplicate --- src/main/java/org/kkumulkkum/server/domain/Participant.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/kkumulkkum/server/domain/Participant.java b/src/main/java/org/kkumulkkum/server/domain/Participant.java index df0ff32..33d13d6 100644 --- a/src/main/java/org/kkumulkkum/server/domain/Participant.java +++ b/src/main/java/org/kkumulkkum/server/domain/Participant.java @@ -11,6 +11,11 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table( + uniqueConstraints = { + @UniqueConstraint(columnNames = {"promise_id", "member_id"}) + } +) public class Participant extends BaseTimeEntity { @Id