diff --git a/server/src/main/java/server/haengdong/application/EventService.java b/server/src/main/java/server/haengdong/application/EventService.java index 94c9dbda1..9ad502606 100644 --- a/server/src/main/java/server/haengdong/application/EventService.java +++ b/server/src/main/java/server/haengdong/application/EventService.java @@ -5,6 +5,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import server.haengdong.application.request.EventAppRequest; import server.haengdong.application.response.ActionAppResponse; import server.haengdong.application.response.EventAppResponse; @@ -20,6 +21,7 @@ import server.haengdong.exception.HaengdongException; @RequiredArgsConstructor +@Transactional(readOnly = true) @Service public class EventService { @@ -28,6 +30,7 @@ public class EventService { private final BillActionRepository billActionRepository; private final MemberActionRepository memberActionRepository; + @Transactional public EventAppResponse saveEvent(EventAppRequest request) { String token = eventTokenProvider.createToken(); Event event = request.toEvent(token); @@ -44,7 +47,8 @@ public EventDetailAppResponse findEvent(String token) { } public List findActions(String token) { - Event event = eventRepository.findByToken(token).orElseThrow(() -> new IllegalArgumentException("")); + Event event = eventRepository.findByToken(token) + .orElseThrow(() -> new HaengdongException(HaengdongErrorCode.NOT_FOUND_EVENT)); List billActions = billActionRepository.findByAction_Event(event).stream() .sorted(Comparator.comparing(BillAction::getSequence)).toList(); diff --git a/server/src/main/java/server/haengdong/domain/action/MemberActionStatus.java b/server/src/main/java/server/haengdong/domain/action/MemberActionStatus.java index afcb31337..0a20817fd 100644 --- a/server/src/main/java/server/haengdong/domain/action/MemberActionStatus.java +++ b/server/src/main/java/server/haengdong/domain/action/MemberActionStatus.java @@ -1,6 +1,8 @@ package server.haengdong.domain.action; import java.util.Arrays; +import server.haengdong.exception.HaengdongErrorCode; +import server.haengdong.exception.HaengdongException; public enum MemberActionStatus { IN, @@ -11,6 +13,7 @@ public static MemberActionStatus of(String status) { return Arrays.stream(MemberActionStatus.values()) .filter(s -> s.name().equals(status)) .findFirst() - .orElseThrow(() -> new IllegalArgumentException("Invalid status: " + status)); + .orElseThrow(() -> new HaengdongException(HaengdongErrorCode.BAD_REQUEST, + "존재하지 않는 인원 변동 액션입니다.")); } } diff --git a/server/src/main/java/server/haengdong/presentation/response/StepResponse.java b/server/src/main/java/server/haengdong/presentation/response/StepResponse.java index 354f019df..54b2b06b9 100644 --- a/server/src/main/java/server/haengdong/presentation/response/StepResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/StepResponse.java @@ -37,8 +37,6 @@ public static StepResponse of(List actions) { } if (currentActionType.equals("BILL")) { actionsResponse.add(ActionsResponse.of(group, members)); - } else { - actionsResponse.add(ActionsResponse.of(group, Set.of())); } currentActionType = typeName; group.clear(); @@ -53,8 +51,6 @@ public static StepResponse of(List actions) { if (currentActionType.equals("BILL")) { actionsResponse.add(ActionsResponse.of(group, members)); - } else { - actionsResponse.add(ActionsResponse.of(group, null)); } return new StepResponse(actionsResponse);