Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 🚩 Jira Ticket
[SCRUM-]
# 🚩 Issue
closed #

# 🗣️ 리뷰 요구사항 (선택)
2 changes: 2 additions & 0 deletions api-owner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

dependencies {
implementation project(':domain')
implementation project(':domain-member')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line adds a dependency on the new :domain-member module. Ensure that this dependency is necessary and doesn't introduce any circular dependencies or conflicts with existing dependencies. Also, verify that the correct version of the module is being used if versioning is in place.

If the dependency is not needed, it should be removed to reduce the project's complexity and build time.

implementation project(':infra-redis')
implementation project(':infra-kafka')

Expand All @@ -12,5 +13,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'

testImplementation(testFixtures(project(':domain')))
testImplementation(testFixtures(project(':domain-member')))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line adds test fixtures for the :domain-member module. Confirm that these test fixtures are actually needed for testing in this module. Test fixtures should only be included if they provide necessary testing utilities or data specific to the :domain-member module.

If the test fixtures are not required, removing them will simplify the build configuration and reduce potential conflicts.

testImplementation 'io.rest-assured:rest-assured'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class ReservationConfirmedEvent {
private final LocalDateTime dateTime;
private final LocalDateTime createdAt;

public ReservationConfirmedEvent(Reservation reservation) {
public ReservationConfirmedEvent(Reservation reservation, String memberName) {
this.reservationId = reservation.getId();
this.memberId = reservation.getMember().getId();
this.memberName = reservation.getMember().getName();
this.memberId = reservation.getMemberId();
this.memberName = memberName;
this.restaurantId = reservation.getRestaurant().getId();
this.restaurantName = reservation.getRestaurantName();
this.status = reservation.getStatus().name();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.wellmeet.reservation;

import com.wellmeet.domain.member.MemberDomainService;
import com.wellmeet.domain.member.entity.Member;
import com.wellmeet.domain.reservation.ReservationDomainService;
import com.wellmeet.domain.reservation.entity.Reservation;
import com.wellmeet.global.event.EventPublishService;
import com.wellmeet.global.event.event.ReservationConfirmedEvent;
import com.wellmeet.reservation.dto.ReservationResponse;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -15,13 +20,34 @@
public class ReservationService {

private final ReservationDomainService reservationDomainService;
private final MemberDomainService memberDomainService;
private final EventPublishService eventPublishService;

@Transactional(readOnly = true)
public List<ReservationResponse> getReservations(String restaurantId) {
return reservationDomainService.findAllByRestaurantId(restaurantId)
.stream()
.map(ReservationResponse::new)
List<Reservation> reservations = reservationDomainService.findAllByRestaurantId(restaurantId);
if (reservations.isEmpty()) {
return List.of();
}

List<String> memberIds = reservations.stream()
.map(Reservation::getMemberId)
.distinct()
.toList();
Map<String, Member> membersById = memberDomainService.findAllByIds(memberIds).stream()
.collect(Collectors.toMap(Member::getId, Function.identity()));

return reservations.stream()
.map(reservation -> {
Member member = membersById.get(reservation.getMemberId());
return new ReservationResponse(
reservation,
member.getName(),
member.getPhone(),
member.getEmail(),
member.isVip()
);
Comment on lines +42 to +49

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

membersById.get(reservation.getMemberId()) 호출 시, 만약 memberIds에 해당하는 Member가 존재하지 않으면 (예: 회원 탈퇴로 인해 데이터 정합성이 깨진 경우) null이 반환될 수 있습니다. 이 경우 member.getName()을 호출할 때 NullPointerException이 발생하여 API 전체가 실패할 수 있습니다. 데이터가 항상 존재한다고 보장할 수 없다면, null 체크를 추가하여 예외 처리를 하는 것이 안전합니다.

                    Member member = membersById.get(reservation.getMemberId());
                    if (member == null) {
                        throw new IllegalStateException("ID에 해당하는 회원을 찾을 수 없습니다: " + reservation.getMemberId());
                    }
                    return new ReservationResponse(
                            reservation,
                            member.getName(),
                            member.getPhone(),
                            member.getEmail(),
                            member.isVip()
                    );

})
.toList();
Comment on lines +40 to 51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

회원 정보가 없는 경우에 대한 null 처리가 필요합니다.

Line 42에서 membersById.get(reservation.getMemberId())는 해당 memberId를 가진 회원이 데이터베이스에 없을 경우 null을 반환할 수 있습니다. 이후 Lines 45-48에서 null인 member에 대해 member.getName() 등을 호출하면 NullPointerException이 발생합니다.

데이터 정합성이 보장된다면 발생하지 않을 수 있지만, 방어적 프로그래밍을 위해 null 체크를 추가하는 것을 권장합니다.

다음과 같이 개선할 수 있습니다:

         return reservations.stream()
                 .map(reservation -> {
                     Member member = membersById.get(reservation.getMemberId());
+                    if (member == null) {
+                        throw new IllegalStateException("Member not found for reservation: " + reservation.getId());
+                    }
                     return new ReservationResponse(
                             reservation,
                             member.getName(),
                             member.getPhone(),
                             member.getEmail(),
                             member.isVip()
                     );
                 })
                 .toList();

또는 null인 경우를 필터링하여 제외:

         return reservations.stream()
+                .map(reservation -> {
+                    Member member = membersById.get(reservation.getMemberId());
+                    if (member == null) {
+                        return null;
+                    }
+                    return new ReservationResponse(
+                            reservation,
+                            member.getName(),
+                            member.getPhone(),
+                            member.getEmail(),
+                            member.isVip()
+                    );
+                })
+                .filter(Objects::nonNull)
-                .map(reservation -> {
-                    Member member = membersById.get(reservation.getMemberId());
-                    return new ReservationResponse(
-                            reservation,
-                            member.getName(),
-                            member.getPhone(),
-                            member.getEmail(),
-                            member.isVip()
-                    );
-                })
                 .toList();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return reservations.stream()
.map(reservation -> {
Member member = membersById.get(reservation.getMemberId());
return new ReservationResponse(
reservation,
member.getName(),
member.getPhone(),
member.getEmail(),
member.isVip()
);
})
.toList();
return reservations.stream()
.map(reservation -> {
Member member = membersById.get(reservation.getMemberId());
if (member == null) {
throw new IllegalStateException("Member not found for reservation: " + reservation.getId());
}
return new ReservationResponse(
reservation,
member.getName(),
member.getPhone(),
member.getEmail(),
member.isVip()
);
})
.toList();
🤖 Prompt for AI Agents
In api-owner/src/main/java/com/wellmeet/reservation/ReservationService.java
around lines 40 to 51, the call membersById.get(reservation.getMemberId()) can
return null and the subsequent member.getX() calls will throw
NullPointerException; add a null check for the retrieved member and handle it
either by supplying safe defaults when constructing ReservationResponse (e.g.,
empty strings and false for isVip) or by filtering out reservations with missing
members before mapping; implement one of these approaches consistently and
ensure no member.get... is called on a null reference.

}

Expand All @@ -30,7 +56,8 @@ public void confirmReservation(Long reservationId) {
Reservation reservation = reservationDomainService.getById(reservationId);
reservation.confirm();

ReservationConfirmedEvent event = new ReservationConfirmedEvent(reservation);
Member member = memberDomainService.getById(reservation.getMemberId());
ReservationConfirmedEvent event = new ReservationConfirmedEvent(reservation, member.getName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ReservationConfirmedEvent is being published with the member's name. Ensure that all necessary data for the event is being passed and that no sensitive information is inadvertently exposed through this event. Consider if other member details are needed and if they should be included.

Also, verify that the member.getName() call does not introduce a performance bottleneck if this method is frequently called.

eventPublishService.publishReservationConfirmedEvent(event);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wellmeet.reservation.dto;

import com.wellmeet.domain.member.entity.Member;
import com.wellmeet.domain.reservation.entity.Reservation;
import com.wellmeet.domain.reservation.entity.ReservationStatus;
import java.time.LocalDate;
Expand All @@ -23,9 +22,14 @@ public class ReservationResponse {
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public ReservationResponse(Reservation reservation) {
Member member = reservation.getMember();
CustomerSummaryResponse customerResponse = new CustomerSummaryResponse(member);
public ReservationResponse(Reservation reservation, String memberName, String memberPhone, String memberEmail, boolean memberVip) {
CustomerSummaryResponse customerResponse = new CustomerSummaryResponse(
reservation.getMemberId(),
memberName,
memberPhone,
memberEmail,
memberVip
);

this.id = reservation.getId();
this.customer = customerResponse;
Expand All @@ -48,12 +52,12 @@ public static class CustomerSummaryResponse {
private String email;
private boolean vip;

public CustomerSummaryResponse(Member member) {
this.id = member.getId();
this.name = member.getName();
this.phone = member.getPhone();
this.email = member.getEmail();
this.vip = member.isVip();
public CustomerSummaryResponse(String id, String name, String phone, String email, boolean vip) {
this.id = id;
this.name = name;
this.phone = phone;
this.email = email;
this.vip = vip;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PublishReservationConfirmedEvent {
AvailableDate availableDate = createAvailableDate(restaurant);
Member member = createMember();
Reservation reservation = createReservation(restaurant, availableDate, member);
ReservationConfirmedEvent event = new ReservationConfirmedEvent(reservation);
ReservationConfirmedEvent event = new ReservationConfirmedEvent(reservation, member.getName());

eventPublishService.publishReservationConfirmedEvent(event);

Expand Down Expand Up @@ -81,6 +81,6 @@ private Member createMember() {
}

private Reservation createReservation(Restaurant restaurant, AvailableDate availableDate, Member member) {
return new Reservation(restaurant, availableDate, member, 4, "request");
return new Reservation(restaurant, availableDate, member.getId(), 4, "request");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HandleReservationConfirmed {
AvailableDate availableDate = createAvailableDate(restaurant);
Member member = createMember();
Reservation reservation = createReservation(restaurant, availableDate, member);
ReservationConfirmedEvent event = new ReservationConfirmedEvent(reservation);
ReservationConfirmedEvent event = new ReservationConfirmedEvent(reservation, member.getName());

reservationEventListener.handleReservationConfirmed(event);

Expand Down Expand Up @@ -72,6 +72,6 @@ private Member createMember() {
}

private Reservation createReservation(Restaurant restaurant, AvailableDate availableDate, Member member) {
return new Reservation(restaurant, availableDate, member, 4, "request");
return new Reservation(restaurant, availableDate, member.getId(), 4, "request");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class GetReservations {
restaurant2);
Member member1 = memberGenerator.generate("mem1");
Member member2 = memberGenerator.generate("mem2");
reservationGenerator.generate(restaurant1, availableDate1, member1, 2);
reservationGenerator.generate(restaurant1, availableDate1, member2, 4);
reservationGenerator.generate(restaurant2, availableDate2, member1, 3);
reservationGenerator.generate(restaurant1, availableDate1, member1.getId(), 2);
reservationGenerator.generate(restaurant1, availableDate1, member2.getId(), 4);
reservationGenerator.generate(restaurant2, availableDate2, member1.getId(), 3);

ReservationResponse[] reservationResponses = given()
.pathParam("restaurantId", restaurant1.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.wellmeet.domain.member.MemberDomainService;
import com.wellmeet.domain.member.entity.Member;
import com.wellmeet.domain.owner.entity.Owner;
import com.wellmeet.domain.reservation.ReservationDomainService;
Expand All @@ -29,6 +30,9 @@ class ReservationServiceTest {
@Mock
private ReservationDomainService reservationDomainService;

@Mock
private MemberDomainService memberDomainService;

@Mock
private EventPublishService eventPublishService;

Expand All @@ -50,6 +54,9 @@ class GetReservations {

when(reservationDomainService.findAllByRestaurantId(restaurant.getId()))
.thenReturn(reservations);
when(memberDomainService.findAllByIds(List.of(member1.getId(), member2.getId())))
.thenReturn(List.of(member1, member2));

Comment on lines +57 to +59
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

null memberId로 인한 의미 없는 검증 가능성 — ID를 명시적으로 세팅하세요

현재 Member를 new로 생성해 getId()가 null일 가능성이 높습니다. 그 결과:

  • findAllByIds가 [null, null]로 스터빙되어 실제 시나리오와 괴리,
  • Reservation에도 null memberId가 저장되어 매핑 검증이 약해집니다.

테스트 신뢰도를 위해 멤버 ID를 고정 값으로 주입하고, 스터빙은 순서에 비의존하게 처리하세요.

아래와 같이 수정 제안합니다.

@@
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
@@
 import java.time.LocalDateTime;
 import java.util.List;
+import org.springframework.test.util.ReflectionTestUtils;
@@
-            when(memberDomainService.findAllByIds(List.of(member1.getId(), member2.getId())))
-                    .thenReturn(List.of(member1, member2));
+            when(memberDomainService.findAllByIds(
+                    argThat(ids -> ids != null
+                            && ids.containsAll(List.of(member1.getId(), member2.getId()))
+                            && ids.size() == 2)))
+                .thenReturn(List.of(member1, member2));
@@
-    private Member createMember(String name) {
-        return new Member(name, "nickname", "email@email.com", "phone");
-    }
+    private Member createMember(String name) {
+        Member member = new Member(name, "nickname", "email@email.com", "phone");
+        // 테스트용 결정적 ID 주입
+        ReflectionTestUtils.setField(member, "id", name + "-id");
+        return member;
+    }

추가로, getReservations 검증을 단순 size 비교에서 DTO 필드(예: memberId, memberName 등)까지 포함하도록 보강해 주세요.

다음 스크립트로 Member 엔티티의 id 필드 존재/타입을 확인해 주세요. ReflectionTestUtils 사용 가능 여부도 함께 탐색합니다.

Also applies to: 103-103


🏁 Script executed:

#!/bin/bash
# Member 엔티티 id 필드 확인
fd -a 'Member.java' | xargs -I {} rg -nP 'class\s+Member\b|^\s*private\s+(String|Long|UUID)\s+id\s*;' -n --context 2 {}

# ReflectionTestUtils 사용 여부(프로젝트 내 선행 사용 사례 탐색)
rg -n 'ReflectionTestUtils' -g 'src/**/test/**'

Length of output: 382


🏁 Script executed:

#!/bin/bash
# ReservationServiceTest.java 전체 확인
fd -a 'ReservationServiceTest.java' -type f

# 찾은 파일의 내용 확인
fd -a 'ReservationServiceTest.java' -type f -exec cat {} \;

Length of output: 341


🏁 Script executed:

#!/bin/bash
# Reservation 클래스 구조 확인
fd -a 'Reservation.java' -type f | grep -v Test | xargs -I {} cat {}

Length of output: 170


🏁 Script executed:

#!/bin/bash
# BaseEntity 확인
fd -a 'BaseEntity.java' -type f | xargs -I {} cat {}

Length of output: 170



🏁 Script executed:

#!/bin/bash
# ReservationServiceTest.java 찾기 및 출력
fd 'ReservationServiceTest\.java$' -exec cat {} \;

Length of output: 187


🏁 Script executed:

#!/bin/bash
# Reservation.java 찾기 및 출력 (Test 제외)
fd 'Reservation\.java$' -not -path '*/test/*' -exec cat {} \;

Length of output: 230


🏁 Script executed:

#!/bin/bash
# BaseEntity.java 찾기 및 출력
fd 'BaseEntity\.java$' -exec cat {} \;

Length of output: 187


List<ReservationResponse> expectedReservations = reservationService.getReservations(restaurant.getId());

assertThat(expectedReservations).hasSize(reservations.size());
Expand All @@ -68,6 +75,8 @@ class ConfirmReservation {

when(reservationDomainService.getById(reservation.getId()))
.thenReturn(reservation);
when(memberDomainService.getById(member.getId()))
.thenReturn(member);

reservationService.confirmReservation(reservation.getId());

Expand All @@ -91,6 +100,6 @@ private Member createMember(String name) {

private Reservation createReservation(Restaurant restaurant, AvailableDate availableDate, Member member,
int partySize) {
return new Reservation(restaurant, availableDate, member, partySize, "request");
return new Reservation(restaurant, availableDate, member.getId(), partySize, "request");
}
}
2 changes: 2 additions & 0 deletions api-user/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

dependencies {
implementation project(':domain')
implementation project(':domain-member')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line adds a dependency on the new :domain-member module. Ensure that this dependency is necessary and doesn't introduce any circular dependencies or conflicts with existing dependencies. Also, verify that the correct version of the module is being used if versioning is in place.

If the dependency is not needed, it should be removed to reduce the project's complexity and build time.

implementation project(':infra-redis')
implementation project(':infra-kafka')

Expand All @@ -12,6 +13,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'

testImplementation(testFixtures(project(':domain')))
testImplementation(testFixtures(project(':domain-member')))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line adds test fixtures for the :domain-member module. Confirm that these test fixtures are actually needed for testing in this module. Test fixtures should only be included if they provide necessary testing utilities or data specific to the :domain-member module.

If the test fixtures are not required, removing them will simplify the build configuration and reduce potential conflicts.

testImplementation 'io.rest-assured:rest-assured'
}

Expand Down
29 changes: 21 additions & 8 deletions api-user/src/main/java/com/wellmeet/favorite/FavoriteService.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.wellmeet.favorite;

import com.wellmeet.domain.member.FavoriteRestaurantDomainService;
import com.wellmeet.domain.member.MemberDomainService;
import com.wellmeet.domain.member.entity.FavoriteRestaurant;
import com.wellmeet.domain.member.entity.Member;
import com.wellmeet.domain.restaurant.RestaurantDomainService;
import com.wellmeet.domain.restaurant.entity.Restaurant;
import com.wellmeet.domain.restaurant.review.ReviewDomainService;
import com.wellmeet.favorite.dto.FavoriteRestaurantResponse;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -19,14 +20,27 @@ public class FavoriteService {

private final FavoriteRestaurantDomainService favoriteRestaurantDomainService;
private final ReviewDomainService reviewDomainService;
private final MemberDomainService memberDomainService;
private final RestaurantDomainService restaurantDomainService;

@Transactional(readOnly = true)
public List<FavoriteRestaurantResponse> getFavoriteRestaurants(String memberId) {
return favoriteRestaurantDomainService.findAllByMemberId(memberId)
.stream()
.map(favoriteRestaurant -> getFavoriteRestaurantResponse(favoriteRestaurant.getRestaurant()))
List<FavoriteRestaurant> favoriteRestaurants = favoriteRestaurantDomainService.findAllByMemberId(memberId);
if (favoriteRestaurants.isEmpty()) {
return List.of();
}

List<String> restaurantIds = favoriteRestaurants.stream()
.map(FavoriteRestaurant::getRestaurantId)
.toList();

Map<String, Restaurant> restaurantsById = restaurantDomainService.findAllByIds(restaurantIds).stream()
.collect(Collectors.toMap(Restaurant::getId, Function.identity()));

return favoriteRestaurants.stream()
.map(favoriteRestaurant -> {
Restaurant restaurant = restaurantsById.get(favoriteRestaurant.getRestaurantId());
return getFavoriteRestaurantResponse(restaurant);
Comment on lines +41 to +42

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

restaurantsById.get(favoriteRestaurant.getRestaurantId()) 호출 시, 만약 restaurantIds에 해당하는 Restaurant가 존재하지 않으면(예: 식당 정보 삭제) null이 반환될 수 있습니다. 이 null 값이 getFavoriteRestaurantResponse 메소드로 전달되면 NullPointerException이 발생할 수 있습니다. null 체크를 추가하여 데이터 불일치 상황에 대비하는 것이 좋습니다.

                    Restaurant restaurant = restaurantsById.get(favoriteRestaurant.getRestaurantId());
                    if (restaurant == null) {
                        throw new IllegalStateException("ID에 해당하는 식당을 찾을 수 없습니다: " + favoriteRestaurant.getRestaurantId());
                    }
                    return getFavoriteRestaurantResponse(restaurant);

})
.toList();
}

Expand All @@ -37,9 +51,8 @@ private FavoriteRestaurantResponse getFavoriteRestaurantResponse(Restaurant rest

@Transactional
public FavoriteRestaurantResponse addFavoriteRestaurant(String memberId, String restaurantId) {
Member member = memberDomainService.getById(memberId);
Restaurant restaurant = restaurantDomainService.getById(restaurantId);
FavoriteRestaurant favoriteRestaurant = new FavoriteRestaurant(member, restaurant);
FavoriteRestaurant favoriteRestaurant = new FavoriteRestaurant(memberId, restaurantId);
favoriteRestaurantDomainService.save(favoriteRestaurant);
return getFavoriteRestaurantResponse(restaurant);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class ReservationCanceledEvent {
private final LocalDateTime dateTime;
private final LocalDateTime createdAt;

public ReservationCanceledEvent(Reservation reservation) {
public ReservationCanceledEvent(Reservation reservation, String memberName) {
this.reservationId = reservation.getId();
this.memberId = reservation.getMember().getId();
this.memberName = reservation.getMember().getName();
this.memberId = reservation.getMemberId();
this.memberName = memberName;
this.restaurantId = reservation.getRestaurant().getId();
this.restaurantName = reservation.getRestaurantName();
this.status = reservation.getStatus().name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class ReservationCreatedEvent {
private final LocalDateTime dateTime;
private final LocalDateTime createdAt;

public ReservationCreatedEvent(Reservation reservation) {
public ReservationCreatedEvent(Reservation reservation, String memberName) {
this.reservationId = reservation.getId();
this.memberId = reservation.getMember().getId();
this.memberName = reservation.getMember().getName();
this.memberId = reservation.getMemberId();
this.memberName = memberName;
this.restaurantId = reservation.getRestaurant().getId();
this.restaurantName = reservation.getRestaurantName();
this.status = reservation.getStatus().name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class ReservationUpdatedEvent {
private final LocalDateTime dateTime;
private final LocalDateTime createdAt;

public ReservationUpdatedEvent(Reservation reservation) {
public ReservationUpdatedEvent(Reservation reservation, String memberName) {
this.reservationId = reservation.getId();
this.memberId = reservation.getMember().getId();
this.memberName = reservation.getMember().getName();
this.memberId = reservation.getMemberId();
this.memberName = memberName;
this.restaurantId = reservation.getRestaurant().getId();
this.restaurantName = reservation.getRestaurantName();
this.status = reservation.getStatus().name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public CreateReservationResponse reserve(String memberId, CreateReservationReque
reservationRedisService.isReserving(memberId, request.getRestaurantId(), request.getAvailableDateId());
Member member = memberDomainService.getById(memberId);
restaurantDomainService.decreaseAvailableDateCapacity(availableDate, request.getPartySize());
Reservation reservation = request.toDomain(availableDate.getRestaurant(), availableDate, member);
Reservation reservation = request.toDomain(availableDate.getRestaurant(), availableDate, memberId);

Reservation savedReservation = reservationDomainService.save(reservation);
ReservationCreatedEvent event = new ReservationCreatedEvent(savedReservation);
ReservationCreatedEvent event = new ReservationCreatedEvent(savedReservation, member.getName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ReservationCreatedEvent is being published with the member's name. Ensure that all necessary data for the event is being passed and that no sensitive information is inadvertently exposed through this event. Consider if other member details are needed and if they should be included.

Also, verify that the member.getName() call does not introduce a performance bottleneck if this method is frequently called.

eventPublishService.publishReservationCreatedEvent(event);

return new CreateReservationResponse(savedReservation);
Expand Down Expand Up @@ -84,7 +84,8 @@ public CreateReservationResponse updateReservation(
request.getSpecialRequest()
);

ReservationUpdatedEvent event = new ReservationUpdatedEvent(reservation);
Member member = memberDomainService.getById(memberId);
ReservationUpdatedEvent event = new ReservationUpdatedEvent(reservation, member.getName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ReservationUpdatedEvent is being published with the member's name. Ensure that all necessary data for the event is being passed and that no sensitive information is inadvertently exposed through this event. Consider if other member details are needed and if they should be included.

Also, verify that the member.getName() call does not introduce a performance bottleneck if this method is frequently called.

eventPublishService.publishReservationUpdatedEvent(event);
return new CreateReservationResponse(reservation);
}
Expand All @@ -96,7 +97,8 @@ public void cancel(Long reservationId, String memberId) {
restaurantDomainService.increaseAvailableDateCapacity(availableDate, reservation.getPartySize());
reservation.cancel();

ReservationCanceledEvent event = new ReservationCanceledEvent(reservation);
Member member = memberDomainService.getById(memberId);
ReservationCanceledEvent event = new ReservationCanceledEvent(reservation, member.getName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ReservationCanceledEvent is being published with the member's name. Ensure that all necessary data for the event is being passed and that no sensitive information is inadvertently exposed through this event. Consider if other member details are needed and if they should be included.

Also, verify that the member.getName() call does not introduce a performance bottleneck if this method is frequently called.

eventPublishService.publishReservationCanceledEvent(event);
}
}
Loading