Skip to content

Commit

Permalink
edit : 무한스크롤 삭제, list 조회로 변경 #112
Browse files Browse the repository at this point in the history
  • Loading branch information
bongsh0112 committed Nov 29, 2023
1 parent 7cf5e76 commit a29a5f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -44,7 +45,7 @@ public RetrieveAnswerCountResponse getAnswerCounts(@PathVariable Long questionId
summary = "특정 유저의 친구들이 해당 데일리 질문에 답변을 남겼는지 조회하고, 남겼다면 답변의 정보를 조회합니다.",
description = "답변을 남기지 않았다면 답변 필드가 null")
@GetMapping("/{userId}/neighbors")
public SliceResponse<NeighborAnswerInfoDTO> getNeighborAnswerInfoList(
public List<NeighborAnswerInfoDTO> getNeighborAnswerInfoList(
@PathVariable Long questionId,
@PathVariable Long userId,
@ParameterObject @PageableDefault(size = 10) Pageable pageable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import tify.server.api.common.slice.SliceResponse;
import tify.server.api.config.security.SecurityUtils;
import tify.server.core.annotation.UseCase;
import tify.server.domain.common.util.SliceUtil;
import tify.server.domain.domains.question.adaptor.AnswerAdaptor;
import tify.server.domain.domains.question.adaptor.DailyQuestionAdaptor;
import tify.server.domain.domains.question.domain.Answer;
Expand Down Expand Up @@ -60,7 +59,7 @@ public SliceResponse<RetrieveAnswerDTO> execute(Long questionId, Pageable pageab
}

@Transactional(readOnly = true)
public SliceResponse<NeighborAnswerInfoDTO> executeNeighborAnswerList(
public List<NeighborAnswerInfoDTO> executeNeighborAnswerList(
Long questionId, Long userId, Pageable pageable) {
List<User> neighborList =
neighborAdaptor.queryAllByFromUserId(userId).stream()
Expand All @@ -77,21 +76,18 @@ public SliceResponse<NeighborAnswerInfoDTO> executeNeighborAnswerList(
.toList();
NeighborCondition neighborCondition =
new NeighborCondition(userId, blockedIdList, friendIdList);
Slice<RetrieveNeighborDTO> neighbors =
neighborAdaptor.searchNeighbors(neighborCondition, pageable);
List<NeighborAnswerInfoDTO> list =
neighbors.stream()
.map(
dto -> {
Optional<Answer> answer =
answerAdaptor.optionalQueryByQuestionAndUser(
questionId, dto.getNeighborId());
return NeighborAnswerInfoDTO.builder()
.neighborInfo(dto)
.answerInfo(AnswerInfoVo.from(answer.orElse(null)))
.build();
})
.toList();
return SliceResponse.of(SliceUtil.valueOf(list, pageable));
List<RetrieveNeighborDTO> neighbors = neighborAdaptor.searchNeighbors(neighborCondition);
return neighbors.stream()
.map(
dto -> {
Optional<Answer> answer =
answerAdaptor.optionalQueryByQuestionAndUser(
questionId, dto.getNeighborId());
return NeighborAnswerInfoDTO.builder()
.neighborInfo(dto)
.answerInfo(AnswerInfoVo.from(answer.orElse(null)))
.build();
})
.toList();
}
}

0 comments on commit a29a5f4

Please sign in to comment.