From f3ed6508def36ac6a40553592bf58a0dbb77a823 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 5 Feb 2025 23:12:22 +0900 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=EB=B0=A9=20=EC=B0=B8=EA=B0=80?= =?UTF-8?q?=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C=ED=96=89=EC=8B=9C=20?= =?UTF-8?q?=ED=98=84=EC=9E=AC=20=EC=B0=B8=EA=B0=80=20=EC=9D=B8=EC=9B=90,?= =?UTF-8?q?=20=EC=B5=9C=EB=8C=80=20=EC=B0=B8=EA=B0=80=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=20=EC=9D=B8=EC=9B=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/AutoMatchingPostRequest.java | 6 ++++++ .../common/service/AutoMatchingService.java | 3 ++- .../matching/event/MatchingEventFactory.java | 4 ++-- .../kafka_topic/MatchMemberJoinedEvent.java | 6 +++++- .../service/kafka/AutoMatchingConsumer.java | 18 +++++++++--------- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java index 527a02de..9110b2de 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -12,9 +12,15 @@ public record AutoMatchingPostRequest( // String destinationName, // 현재 사용하는 필드 + @NotNull String startName, + + @NotNull String destinationName, + + @NotNull List criteria, + @NotNull List members, diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java index 9dfad52b..0d2b32aa 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/AutoMatchingService.java @@ -78,7 +78,8 @@ private void sendMatchRoomCreatedEvent(Long memberId, private void sendMatchMemberJoinedEvent(Long memberId, FindRoomResult roomResult) { Long roomId = roomResult.roomId(); - this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId, roomResult.chattingRoomId())); + this.autoMatchingProducer.sendEvent(this.matchingEventFactory.createMatchMemberJoinedEvent(roomId, memberId, roomResult.chattingRoomId(), + roomResult.currentMembers(), roomResult.maxCapacity())); } public AutoMatchingPostResponse handlerAutoCancelMatching(Long memberId, diff --git a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java index b23ec787..ed86b65c 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/MatchingEventFactory.java @@ -37,8 +37,8 @@ public MatchMemberCancelledEvent createMatchMemberCancelledEvent(Long roomId, Lo return MatchMemberCancelledEvent.of(roomId, memberId, this.matchMemberCancelledTopic); } - public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId, Long chattingRoomId) { - return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic, chattingRoomId); + public MatchMemberJoinedEvent createMatchMemberJoinedEvent(Long roomId, Long memberId, Long chattingRoomId, Integer nowMemberCount, Integer autoMaxCapacity) { + return MatchMemberJoinedEvent.of(roomId, memberId, this.matchMemberJoinedTopic, chattingRoomId, nowMemberCount, autoMaxCapacity); } public MatchRoomCancelledEvent createMatchRoomCancelledEvent(Long roomId) { diff --git a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java index a727ed34..7e215ad9 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/dto/kafka_topic/MatchMemberJoinedEvent.java @@ -11,6 +11,8 @@ public record MatchMemberJoinedEvent( Long roomId, Long memberId, Long chattingRoomId, + Integer nowMemberCount, + Integer maxCapacity, @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime joinedAt, @@ -28,12 +30,14 @@ public String getTopic() { return this.topic; } - public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic, Long chattingRoomId) { + public static MatchMemberJoinedEvent of(Long roomId, Long memberId, String topic, Long chattingRoomId, Integer nowMemberCount, Integer autoMaxCapacity) { return MatchMemberJoinedEvent.builder() .roomId(roomId) .memberId(memberId) .topic(topic) .chattingRoomId(chattingRoomId) + .nowMemberCount(nowMemberCount) + .maxCapacity(autoMaxCapacity) .build(); } } diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index 3ff71aca..c4d9c1b1 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -28,17 +28,17 @@ public class AutoMatchingConsumer { topics = "${gachtaxi.kafka.topics.match-room-created}", containerFactory = "matchRoomCreatedEventListenerFactory" ) - public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) { - try { - log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); + public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) { + try { + log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); - this.sseService.sendToClient( - event.roomMasterId(), - "MATCH_ROOM_CREATED", - this.matchingRoomService.createMatchingRoom(event) - ); + this.sseService.sendToClient( + event.roomMasterId(), + "MATCH_ROOM_CREATED", + this.matchingRoomService.createMatchingRoom(event) + ); - ack.acknowledge(); + ack.acknowledge(); } catch (Exception e) { log.error("[KAFKA CONSUMER] Error processing MatchRoomCreatedEvent", e); this.sseService.sendToClient(event.roomMasterId(), "MATCH_ROOM_CREATED", e.getMessage()); From b94617a4a4096679ae76e1cf3b9ba8eb7bb1b31b Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 5 Feb 2025 23:13:28 +0900 Subject: [PATCH 2/5] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=9A=94=EC=B2=AD=20DTO=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/dto/request/AutoMatchingPostRequest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java index 9110b2de..c94568fd 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/dto/request/AutoMatchingPostRequest.java @@ -18,10 +18,8 @@ public record AutoMatchingPostRequest( @NotNull String destinationName, - @NotNull List criteria, - @NotNull List members, @Min(value = 4000) From 049f48e56cc22ba0e3c4e4e4301ad8aeb00b5a18 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 5 Feb 2025 23:20:36 +0900 Subject: [PATCH 3/5] =?UTF-8?q?refactor:=20=EC=9E=90=EB=8F=99=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EB=B0=A9=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C=ED=96=89=20=EC=A0=84=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EB=90=9C=20=EB=B0=A9=20DB=EC=97=90=20?= =?UTF-8?q?=EB=84=A3=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/event/service/kafka/AutoMatchingConsumer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java index c4d9c1b1..ae56d5f0 100644 --- a/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java +++ b/src/main/java/com/gachtaxi/domain/matching/event/service/kafka/AutoMatchingConsumer.java @@ -32,10 +32,12 @@ public void onMatchRoomCreated(MatchRoomCreatedEvent event, Acknowledgment ack) try { log.info("[KAFKA CONSUMER] Received MatchRoomCreatedEvent: {}", event); + MatchRoomCreatedEvent createdEvent = this.matchingRoomService.createMatchingRoom(event); + this.sseService.sendToClient( event.roomMasterId(), "MATCH_ROOM_CREATED", - this.matchingRoomService.createMatchingRoom(event) + createdEvent ); ack.acknowledge(); From c801e7baf80962960706667611b3c61c17a629d3 Mon Sep 17 00:00:00 2001 From: senna Date: Wed, 5 Feb 2025 23:25:51 +0900 Subject: [PATCH 4/5] =?UTF-8?q?hotfix:=20=EB=A7=A4=EC=B9=AD=20=EB=B0=A9=20?= =?UTF-8?q?=EC=B0=B8=EA=B0=80=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=EC=97=90=20now?= =?UTF-8?q?MemberCount=EA=B0=80=20null=EB=A1=9C=20=EB=93=A4=EC=96=B4?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gachtaxi/domain/matching/common/entity/MatchingRoom.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java index 37b7112c..d18bdde3 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/entity/MatchingRoom.java @@ -150,6 +150,7 @@ public FindRoomResult toFindRoomResult() { .roomId(this.getId()) .maxCapacity(this.getCapacity()) .chattingRoomId(this.chattingRoomId) + .currentMembers(this.getCurrentMemberCount()) .build(); } public int getCurrentMemberCount() { From a35bb504effed2aa0ed641948361fd138891c12f Mon Sep 17 00:00:00 2001 From: huncozyboy Date: Wed, 5 Feb 2025 23:36:30 +0900 Subject: [PATCH 5/5] =?UTF-8?q?hotfix=20:=20=EC=88=98=EB=8F=99=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=20=EC=88=98=EB=9D=BD=EC=8B=9C=EC=97=90=EB=8F=84=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../matching/common/service/MatchingInvitationService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java index cdc5470d..f12ffa0a 100644 --- a/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java +++ b/src/main/java/com/gachtaxi/domain/matching/common/service/MatchingInvitationService.java @@ -96,5 +96,7 @@ public void acceptInvitation(Long userId, ManualMatchingInviteReplyRequest reque MemberMatchingRoomChargingInfo memberInfo = MemberMatchingRoomChargingInfo.notPayedOf(matchingRoom, member); memberMatchingRoomChargingInfoRepository.save(memberInfo); + + notificationRepository.delete(notification); } }