Skip to content

Commit

Permalink
feat: #159 SliceResponse 매퍼 메서드 답변 페이징 구현 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
jaewonLeeKOR committed Sep 16, 2024
1 parent 7c5f48c commit 8daf05e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.server.capple.domain.answer.mapper;

import com.server.capple.domain.answer.dao.AnswerRDBDao.AnswerInfoInterface;
import com.server.capple.domain.answer.dto.AnswerRequest;
import com.server.capple.domain.answer.dto.AnswerResponse.AnswerInfo;
import com.server.capple.domain.answer.dto.AnswerResponse.AnswerList;
Expand All @@ -9,8 +8,6 @@
import com.server.capple.domain.answer.entity.Answer;
import com.server.capple.domain.member.entity.Member;
import com.server.capple.domain.question.entity.Question;
import com.server.capple.global.common.SliceResponse;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Component;

import java.util.List;
Expand Down Expand Up @@ -62,15 +59,4 @@ public MemberAnswerInfo toMemberAnswerInfo(Answer answer, int heartCount, Boolea
public MemberAnswerList toMemberAnswerList(List<MemberAnswerInfo> memberAnswerInfos) {
return new MemberAnswerList(memberAnswerInfos);
}

public SliceResponse<AnswerInfo> toAnswerInfoSliceResponse(Slice<AnswerInfoInterface> answerInfoSliceInterface, List<AnswerInfo> content) {
return SliceResponse.<AnswerInfo>builder()
.number(answerInfoSliceInterface.getNumber())
.size(answerInfoSliceInterface.getSize())
.content(content)
.numberOfElements(answerInfoSliceInterface.getNumberOfElements())
.hasPrevious(answerInfoSliceInterface.hasPrevious())
.hasNext(answerInfoSliceInterface.hasNext())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public AnswerLike toggleAnswerHeart(Member loginMember, Long answerId) {
public SliceResponse<AnswerInfo> getAnswerList(Long memberId, Long questionId, Pageable pageable) {
Slice<AnswerInfoInterface> answerInfoSliceInterface = answerRepository.findByQuestion(questionId, pageable).orElseThrow(()
-> new RestApiException(AnswerErrorCode.ANSWER_NOT_FOUND));
return answerMapper.toAnswerInfoSliceResponse(answerInfoSliceInterface, answerInfoSliceInterface.getContent().stream().map(
return SliceResponse.toSliceResponse(answerInfoSliceInterface, answerInfoSliceInterface.getContent().stream().map(
answerInfoDto -> answerMapper.toAnswerInfo(
answerInfoDto.getAnswer(),
memberId,
Expand Down

0 comments on commit 8daf05e

Please sign in to comment.