Skip to content

Commit

Permalink
�fix: 액션 이력 조회 오류 수정 (#124)
Browse files Browse the repository at this point in the history
* fix: HaengdongException 적용 안된 부분 적용

* fix: Transactional 추가 및 StepResponse 로직 수정
  • Loading branch information
kunsanglee authored Jul 25, 2024
1 parent b9870ed commit ff2632d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +21,7 @@
import server.haengdong.exception.HaengdongException;

@RequiredArgsConstructor
@Transactional(readOnly = true)
@Service
public class EventService {

Expand All @@ -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);
Expand All @@ -44,7 +47,8 @@ public EventDetailAppResponse findEvent(String token) {
}

public List<ActionAppResponse> findActions(String token) {
Event event = eventRepository.findByToken(token).orElseThrow(() -> new IllegalArgumentException(""));
Event event = eventRepository.findByToken(token)
.orElseThrow(() -> new HaengdongException(HaengdongErrorCode.NOT_FOUND_EVENT));

List<BillAction> billActions = billActionRepository.findByAction_Event(event).stream()
.sorted(Comparator.comparing(BillAction::getSequence)).toList();
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
"존재하지 않는 인원 변동 액션입니다."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public static StepResponse of(List<ActionAppResponse> actions) {
}
if (currentActionType.equals("BILL")) {
actionsResponse.add(ActionsResponse.of(group, members));
} else {
actionsResponse.add(ActionsResponse.of(group, Set.of()));
}
currentActionType = typeName;
group.clear();
Expand All @@ -53,8 +51,6 @@ public static StepResponse of(List<ActionAppResponse> actions) {

if (currentActionType.equals("BILL")) {
actionsResponse.add(ActionsResponse.of(group, members));
} else {
actionsResponse.add(ActionsResponse.of(group, null));
}

return new StepResponse(actionsResponse);
Expand Down

0 comments on commit ff2632d

Please sign in to comment.