Skip to content

Commit

Permalink
Chore/170: 실행목표 조회 API 응답 수정 (#171)
Browse files Browse the repository at this point in the history
* fix: 멤버의 실행목표 조회 API 수정

* fix: 조회 API 응답값 수정
  • Loading branch information
clean2001 authored Aug 19, 2024
1 parent 8759c3b commit 25b509d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import jakarta.validation.constraints.NotNull;
import lombok.Builder;
import org.layer.domain.actionItem.dto.ActionItemResponse;
import org.layer.domain.actionItem.enums.ActionItemStatus;

import java.time.LocalDateTime;
import java.util.List;

@Builder
Expand All @@ -15,6 +17,12 @@ public record RetrospectActionItemResponse(@NotNull
@Schema(description = "회고 제목", example = "중간 발표 이후 회고")
String retrospectTitle,
@NotNull
@Schema(description = "회고 마감일")
LocalDateTime deadline,
@NotNull
@Schema(description = "실행 목표 상태")
ActionItemStatus status,
@NotNull
@Schema(description = "액션 아이템 아이디와 내용 리스트")
List<ActionItemResponse> actionItemList) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import org.layer.domain.actionItem.enums.ActionItemStatus;
import org.layer.domain.actionItem.exception.ActionItemException;
import org.layer.domain.actionItem.repository.ActionItemRepository;
import org.layer.domain.answer.entity.Answer;
import org.layer.domain.answer.enums.AnswerStatus;
import org.layer.domain.answer.repository.AnswerRepository;
import org.layer.domain.retrospect.entity.Retrospect;
import org.layer.domain.retrospect.repository.RetrospectRepository;
Expand All @@ -26,7 +24,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -123,7 +120,14 @@ public SpaceRetrospectActionItemGetResponse getSpaceActionItemList(Long memberId
List<ActionItem> actionItemList = actionItemRepository.findAllByRetrospectIdIn(doneRetrospectIds);

List<RetrospectActionItemResponse> responses = new ArrayList<>();
for (Retrospect doneRetrospect : doneRetrospects) {
for (int index = 0; index < doneRetrospects.size(); index++) {
Retrospect doneRetrospect = doneRetrospects.get(index);
ActionItemStatus status;
if(index == 0L) {
status = ActionItemStatus.PROCEEDING;
} else {
status = ActionItemStatus.DONE;
}

List<ActionItemResponse> actionItems = actionItemList.stream()
.filter(ai -> ai.getRetrospectId().equals(doneRetrospect.getId()))
Expand All @@ -134,6 +138,8 @@ public SpaceRetrospectActionItemGetResponse getSpaceActionItemList(Long memberId
.retrospectId(doneRetrospect.getId())
.retrospectTitle(doneRetrospect.getTitle())
.actionItemList(actionItems)
.deadline(doneRetrospect.getDeadline())
.status(status)
.build();

responses.add(response);
Expand Down Expand Up @@ -209,8 +215,6 @@ public MemberActionItemGetResponse getMemberActionItemList(Long currentMemberId)
.sorted(Comparator.comparingInt(ActionItem::getActionItemOrder)) // order 순으로 정렬
.map(ActionItemResponse::of).toList();

// 답변 찾기
List<Answer> answerList = answerRepository.findAllByRetrospectIdAndMemberIdAndAnswerStatus(dto.getRetrospectId(), currentMemberId, AnswerStatus.DONE);

// 상태 확인
ActionItemStatus status;
Expand All @@ -224,9 +228,6 @@ public MemberActionItemGetResponse getMemberActionItemList(Long currentMemberId)
dto.updateActionItemList(actionItems);
dto.updateStatus(status);

LocalDateTime answeredAt = answerList.isEmpty() ? null : answerList.get(0).getCreatedAt();
dto.updateAnsweredAt(answeredAt);

}

return new MemberActionItemGetResponse(dtoList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class MemberActionItemResponse {
@NotNull
String spaceName;
@NotNull
LocalDateTime answeredAt;
LocalDateTime deadline;

@NotNull
ActionItemStatus status;

Expand All @@ -38,7 +39,6 @@ public class MemberActionItemResponse {
public MemberActionItemResponse(Space space,
Retrospect retrospect,
List<ActionItem> actionItemList,
LocalDateTime answeredAt,
ActionItemStatus status) {
List<ActionItemResponse> actionItemResList = actionItemList.stream().map(ActionItemResponse::of).toList();

Expand All @@ -47,7 +47,7 @@ public MemberActionItemResponse(Space space,
this.spaceId = space.getId();
this.spaceName = space.getName();
this.actionItemList = actionItemResList;
this.answeredAt = answeredAt;
this.deadline = retrospect.getDeadline();
this.status = status;
}

Expand All @@ -56,17 +56,14 @@ public MemberActionItemResponse(Space space,
this.retrospectId = retrospect.getId();
this.retrospectTitle = retrospect.getTitle();
this.spaceId = space.getId();
this.deadline = retrospect.getDeadline();
this.spaceName = space.getName();
}

public void updateActionItemList(List<ActionItemResponse> actionItemList) {
this.actionItemList = actionItemList;
}

public void updateAnsweredAt(LocalDateTime answeredAt) {
this.answeredAt = answeredAt;
}

public void updateStatus(ActionItemStatus status) {
this.status = status;
}
Expand Down

0 comments on commit 25b509d

Please sign in to comment.