From ff2632dccbfa63a980cc3cdb1bb98854e055278d Mon Sep 17 00:00:00 2001 From: kunsanglee <85242378+kunsanglee@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:08:42 +0900 Subject: [PATCH] =?UTF-8?q?=08fix:=20=EC=95=A1=EC=85=98=20=EC=9D=B4?= =?UTF-8?q?=EB=A0=A5=20=EC=A1=B0=ED=9A=8C=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#124)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: HaengdongException 적용 안된 부분 적용 * fix: Transactional 추가 및 StepResponse 로직 수정 --- .../java/server/haengdong/application/EventService.java | 6 +++++- .../server/haengdong/domain/action/MemberActionStatus.java | 5 ++++- .../haengdong/presentation/response/StepResponse.java | 4 ---- 3 files changed, 9 insertions(+), 6 deletions(-) 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);