diff --git a/src/main/java/com/server/capple/domain/answer/controller/AnswerController.java b/src/main/java/com/server/capple/domain/answer/controller/AnswerController.java index 21d82ec1..1fe81a02 100644 --- a/src/main/java/com/server/capple/domain/answer/controller/AnswerController.java +++ b/src/main/java/com/server/capple/domain/answer/controller/AnswerController.java @@ -35,19 +35,17 @@ public BaseResponse createAnswer(@AuthMember Member mem } @Operation(summary = "질문에 대한 답변 조회 API", description = "특정 질문에 대한 답변리스트를 조회하는 API입니다." - + "pathVariable으로 questionId를 주세요.") + + "pathVariable으로 questionId를 주세요.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @GetMapping("/question/{questionId}") public BaseResponse> getAnswerList( @AuthMember Member member, @Parameter(description = "질문 식별자") @PathVariable(value = "questionId") Long questionId, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @Parameter(description = "조회할 페이지 번호
0부터 시작") - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, @Parameter(description = "조회할 페이지 크기") @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { - return BaseResponse.onSuccess(answerService.getAnswerList(member.getId(), questionId, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + return BaseResponse.onSuccess(answerService.getAnswerList(member.getId(), questionId, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } @Operation(summary = "답변 수정 API", description = " 답변 수정 API 입니다." + @@ -72,29 +70,25 @@ public BaseResponse toggleAnswerHeart(@AuthMember Mem return BaseResponse.onSuccess(answerService.toggleAnswerHeart(member, answerId)); } - @Operation(summary = "작성한 답변 조회 API", description = " 작성한 답변 조회 API 입니다.") + @Operation(summary = "작성한 답변 조회 API", description = " 작성한 답변 조회 API 입니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @GetMapping public BaseResponse> getMemberAnswer( @AuthMember Member member, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @Parameter(description = "조회할 페이지 번호
0부터 시작") - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, @Parameter(description = "조회할 페이지 크기") @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { - return BaseResponse.onSuccess(answerService.getMemberAnswer(member, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + return BaseResponse.onSuccess(answerService.getMemberAnswer(member, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } - @Operation(summary = "좋아한 답변 조회 API", description = " 좋아한 답변 조회 API 입니다.") + @Operation(summary = "좋아한 답변 조회 API", description = " 좋아한 답변 조회 API 입니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @GetMapping("/heart") public BaseResponse> getMemberHeartAnswer( @AuthMember Member member, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @Parameter(description = "조회할 페이지 번호
0부터 시작") - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, @Parameter(description = "조회할 페이지 크기") @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { - return BaseResponse.onSuccess(answerService.getMemberHeartAnswer(member, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + return BaseResponse.onSuccess(answerService.getMemberHeartAnswer(member, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } } diff --git a/src/main/java/com/server/capple/domain/answer/dao/AnswerRDBDao.java b/src/main/java/com/server/capple/domain/answer/dao/AnswerRDBDao.java index f3e55c83..9ae30eb3 100644 --- a/src/main/java/com/server/capple/domain/answer/dao/AnswerRDBDao.java +++ b/src/main/java/com/server/capple/domain/answer/dao/AnswerRDBDao.java @@ -6,5 +6,8 @@ public class AnswerRDBDao { public interface AnswerInfoInterface { public Answer getAnswer(); public Boolean getIsReported(); + public Long getWriterId(); + public String getWriterProfileImage(); + public String getWriterNickname(); } } diff --git a/src/main/java/com/server/capple/domain/answer/mapper/AnswerMapper.java b/src/main/java/com/server/capple/domain/answer/mapper/AnswerMapper.java index 95c70918..f4fa295c 100644 --- a/src/main/java/com/server/capple/domain/answer/mapper/AnswerMapper.java +++ b/src/main/java/com/server/capple/domain/answer/mapper/AnswerMapper.java @@ -1,5 +1,6 @@ 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.MemberAnswerInfo; @@ -8,8 +9,6 @@ import com.server.capple.domain.question.entity.Question; import org.springframework.stereotype.Component; -import java.util.List; - @Component public class AnswerMapper { public Answer toAnswerEntity(AnswerRequest request, Member member, Question question) { @@ -20,17 +19,17 @@ public Answer toAnswerEntity(AnswerRequest request, Member member, Question ques .build(); } - public AnswerInfo toAnswerInfo(Answer answer, Long memberId, Boolean isReported, Boolean isLiked, Boolean isMine) { + public AnswerInfo toAnswerInfo(AnswerInfoInterface answerInfoDto, Long memberId, Boolean isLiked) { return AnswerInfo.builder() - .answerId(answer.getId()) - .writerId(answer.getMember().getId()) - .profileImage(answer.getMember().getProfileImage()) - .nickname(answer.getMember().getNickname()) - .content(answer.getContent()) - .isMine(isMine) - .isReported(isReported) + .answerId(answerInfoDto.getAnswer().getId()) + .writerId(answerInfoDto.getWriterId()) + .profileImage(answerInfoDto.getWriterProfileImage()) + .nickname(answerInfoDto.getWriterNickname()) + .content(answerInfoDto.getAnswer().getContent()) + .isMine(answerInfoDto.getWriterId().equals(memberId)) + .isReported(answerInfoDto.getIsReported()) .isLiked(isLiked) - .writeAt(answer.getCreatedAt().toString()) + .writeAt(answerInfoDto.getAnswer().getCreatedAt().toString()) .build(); } diff --git a/src/main/java/com/server/capple/domain/answer/repository/AnswerRepository.java b/src/main/java/com/server/capple/domain/answer/repository/AnswerRepository.java index 72393a0e..4c19280e 100644 --- a/src/main/java/com/server/capple/domain/answer/repository/AnswerRepository.java +++ b/src/main/java/com/server/capple/domain/answer/repository/AnswerRepository.java @@ -16,18 +16,24 @@ public interface AnswerRepository extends JpaRepository { Optional findById(Long answerId); - Slice findByIdInAndIdIsLessThanEqual(Set answerIds, Long lastIndex, Pageable pageable); + @Query("SELECT a FROM Answer a WHERE (a.id < :lastIndex OR :lastIndex IS NULL) AND a.id IN :answerIds") + Slice findByIdInAndIdIsLessThan(Set answerIds, Long lastIndex, Pageable pageable); boolean existsByQuestionAndMember(Question question, Member member); - @Query("SELECT a AS answer, (r IS NOT NULL) AS isReported " + + @Query("SELECT a AS answer, " + + "(r IS NOT NULL) AS isReported, " + + "a.member.id AS writerId, " + + "a.member.profileImage AS writerProfileImage, " + + "a.member.nickname AS writerNickname "+ "FROM Answer a " + "LEFT JOIN " + "Report r ON r.answer = a " + - "WHERE a.id <= :lastIndex AND a.question.id = :questionId") + "WHERE (a.id < :lastIndex OR :lastIndex IS NULL) AND a.question.id = :questionId") Slice findByQuestion(@Param("questionId") Long questionId, Long lastIndex, Pageable pageable); - Slice findByMemberAndIdIsLessThanEqual(@Param("member") Member member, Long lastIndex, Pageable pageable); + @Query("SELECT a FROM Answer a WHERE (a.id < :lastIndex OR :lastIndex IS NULL) AND a.member = :member") + Slice findByMemberAndIdIsLessThan(@Param("member") Member member, Long lastIndex, Pageable pageable); @Query("SELECT COUNT(a) FROM Answer a WHERE a.question.id = :questionId") Integer getAnswerCountByQuestionId(Long questionId); diff --git a/src/main/java/com/server/capple/domain/answer/service/AnswerServiceImpl.java b/src/main/java/com/server/capple/domain/answer/service/AnswerServiceImpl.java index 6acb5c33..2a4705eb 100644 --- a/src/main/java/com/server/capple/domain/answer/service/AnswerServiceImpl.java +++ b/src/main/java/com/server/capple/domain/answer/service/AnswerServiceImpl.java @@ -99,16 +99,13 @@ public AnswerLike toggleAnswerHeart(Member loginMember, Long answerId) { @Override public SliceResponse getAnswerList(Long memberId, Long questionId, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); Slice answerInfoSliceInterface = answerRepository.findByQuestion(questionId, lastIndex, pageable); - lastIndex = getLastIndexFromAnswerInfoInterface(lastIndex, answerInfoSliceInterface); + lastIndex = getLastIndexFromAnswerInfoInterface(answerInfoSliceInterface); return SliceResponse.toSliceResponse(answerInfoSliceInterface, answerInfoSliceInterface.getContent().stream().map( answerInfoDto -> answerMapper.toAnswerInfo( - answerInfoDto.getAnswer(), + answerInfoDto, memberId, - answerInfoDto.getIsReported(), - answerHeartRedisRepository.isMemberLikedAnswer(memberId, answerInfoDto.getAnswer().getId()), - answerInfoDto.getAnswer().getMember().getId().equals(memberId) + answerHeartRedisRepository.isMemberLikedAnswer(memberId, answerInfoDto.getAnswer().getId()) ) ).toList(), lastIndex.toString(), answerCountService.getQuestionAnswerCount(questionId)); } @@ -116,9 +113,8 @@ public SliceResponse getAnswerList(Long memberId, Long questionId, L // 유저가 작성한 답변 조회 @Override public SliceResponse getMemberAnswer(Member member, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); - Slice answerSlice = answerRepository.findByMemberAndIdIsLessThanEqual(member, lastIndex, pageable); - lastIndex = getLastIndexFromAnswer(lastIndex, answerSlice); + Slice answerSlice = answerRepository.findByMemberAndIdIsLessThan(member, lastIndex, pageable); + lastIndex = getLastIndexFromAnswer(answerSlice); return SliceResponse.toSliceResponse( answerSlice, answerSlice.getContent().stream() .map(answer -> answerMapper.toMemberAnswerInfo( @@ -132,9 +128,8 @@ public SliceResponse getMemberAnswer(Member member, Long lastI // 유저가 좋아한 답변 조회 //TODO 좋아요니까 좋아요한 순으로 정렬해야할거같은데 Answer의 createAt으로 하고 있음 @Override public SliceResponse getMemberHeartAnswer(Member member, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); - Slice answerSlice = answerRepository.findByIdInAndIdIsLessThanEqual(answerHeartRedisRepository.getMemberHeartsAnswer(member.getId()), lastIndex, pageable); - lastIndex = getLastIndexFromAnswer(lastIndex, answerSlice); + Slice answerSlice = answerRepository.findByIdInAndIdIsLessThan(answerHeartRedisRepository.getMemberHeartsAnswer(member.getId()), lastIndex, pageable); + lastIndex = getLastIndexFromAnswer(answerSlice); return SliceResponse.toSliceResponse(answerSlice, answerSlice.getContent().stream() .map(answer -> answerMapper.toMemberAnswerInfo( answer, @@ -159,20 +154,16 @@ public Answer findAnswer(Long answerId) { ); } - private Long getLastIndex(Long lastIndex) { - return lastIndex == null ? Long.MAX_VALUE : lastIndex; + private Long getLastIndexFromAnswerInfoInterface(Slice answerInfoSliceInterface) { + if(answerInfoSliceInterface.hasContent()) + return answerInfoSliceInterface.stream().map(AnswerInfoInterface::getAnswer).map(Answer::getId).min(Long::compareTo).get(); + return -1L; } - private Long getLastIndexFromAnswerInfoInterface(Long lastIndex, Slice answerInfoSliceInterface) { - if(answerInfoSliceInterface.hasContent() && lastIndex == Long.MAX_VALUE) - return answerInfoSliceInterface.stream().map(AnswerInfoInterface::getAnswer).map(Answer::getId).max(Long::compareTo).get(); - return lastIndex; - } - - private Long getLastIndexFromAnswer(Long lastIndex, Slice answerSlice) { - if (answerSlice.hasContent() && lastIndex == Long.MAX_VALUE) - return answerSlice.stream().map(Answer::getId).max(Long::compareTo).get(); - return lastIndex; + private Long getLastIndexFromAnswer(Slice answerSlice) { + if (answerSlice.hasContent()) + return answerSlice.stream().map(Answer::getId).min(Long::compareTo).get(); + return -1L; } @Getter diff --git a/src/main/java/com/server/capple/domain/board/controller/BoardController.java b/src/main/java/com/server/capple/domain/board/controller/BoardController.java index 242734b2..c7db0049 100644 --- a/src/main/java/com/server/capple/domain/board/controller/BoardController.java +++ b/src/main/java/com/server/capple/domain/board/controller/BoardController.java @@ -49,7 +49,7 @@ private BaseResponse updateBoard(@AuthMember Member member, return BaseResponse.onSuccess(boardService.updateBoard(member, request.getBoardId(), request.getContent())); } - @Operation(summary = "카테고리별 게시글 조회 with REDIS API(프론트 사용 X, 성능 테스트 용)", description = "카테고리별 게시글을 조회합니다.") + @Operation(summary = "카테고리별 게시글 조회 with REDIS API(프론트 사용 X, 성능 테스트 용)", description = "카테고리별 게시글을 조회합니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @ApiResponses(value = { @ApiResponse(responseCode = "COMMON200", description = "성공"), }) @@ -57,14 +57,14 @@ private BaseResponse updateBoard(@AuthMember Member member, public BaseResponse> getBoardsByBoardTypeWithRedis( @AuthMember Member member, @RequestParam(name = "boardType", required = false) BoardType boardType, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, @RequestParam(defaultValue = "1000", required = false) Integer pageSize + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, + @RequestParam(defaultValue = "1000", required = false) Integer pageSize ) { - return BaseResponse.onSuccess(boardService.getBoardsByBoardTypeWithRedis(member, boardType, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + return BaseResponse.onSuccess(boardService.getBoardsByBoardTypeWithRedis(member, boardType, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } - @Operation(summary = "카테고리별 게시글 조회", description = "카테고리별 게시글을 조회합니다.") + @Operation(summary = "카테고리별 게시글 조회", description = "카테고리별 게시글을 조회합니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @ApiResponses(value = { @ApiResponse(responseCode = "COMMON200", description = "성공"), }) @@ -72,25 +72,24 @@ public BaseResponse> getBoardsByBoardTypeWithRedis( public BaseResponse> getBoardsByBoardType( @AuthMember Member member, @RequestParam(name = "boardType", required = false) BoardType boardType, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, @RequestParam(defaultValue = "1000", required = false) Integer pageSize + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, + @RequestParam(defaultValue = "1000", required = false) Integer pageSize ) { - return BaseResponse.onSuccess(boardService.getBoardsByBoardType(member, boardType, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + return BaseResponse.onSuccess(boardService.getBoardsByBoardType(member, boardType, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } - @Operation(summary = "게시글 검색 API", description = "게시글을 검색합니다. 자유게시판에서만 검색이 가능합니다.") + @Operation(summary = "게시글 검색 API", description = "게시글을 검색합니다. 자유게시판에서만 검색이 가능합니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @ApiResponses(value = { @ApiResponse(responseCode = "COMMON200", description = "성공"), }) @GetMapping("/search") public BaseResponse> searchBoardsByKeyword( @AuthMember Member member, @RequestParam(name = "keyword") String keyword, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { - return BaseResponse.onSuccess(boardService.searchBoardsByKeyword(member, keyword, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + return BaseResponse.onSuccess(boardService.searchBoardsByKeyword(member, keyword, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } diff --git a/src/main/java/com/server/capple/domain/board/dao/BoardInfoInterface.java b/src/main/java/com/server/capple/domain/board/dao/BoardInfoInterface.java index 8f46159c..90ff9db0 100644 --- a/src/main/java/com/server/capple/domain/board/dao/BoardInfoInterface.java +++ b/src/main/java/com/server/capple/domain/board/dao/BoardInfoInterface.java @@ -6,4 +6,5 @@ public interface BoardInfoInterface { Board getBoard(); Boolean getIsLike(); Boolean getIsMine(); + String getWriterNickname(); } diff --git a/src/main/java/com/server/capple/domain/board/mapper/BoardMapper.java b/src/main/java/com/server/capple/domain/board/mapper/BoardMapper.java index 7993c684..ada48aa6 100644 --- a/src/main/java/com/server/capple/domain/board/mapper/BoardMapper.java +++ b/src/main/java/com/server/capple/domain/board/mapper/BoardMapper.java @@ -21,11 +21,11 @@ public Board toBoard(Member member, BoardType boardType, String content) { } //redis - public BoardInfo toBoardInfo(Board board, Integer boardHeartsCount, Boolean isLiked, Boolean isMine) { + public BoardInfo toBoardInfo(Board board, String writerNickname, Integer boardHeartsCount, Boolean isLiked, Boolean isMine) { return BoardInfo.builder() .boardId(board.getId()) .writerId(board.getWriter().getId()) - .writerNickname(board.getWriter().getNickname()) + .writerNickname(writerNickname) .content(board.getContent()) .heartCount(boardHeartsCount) .commentCount(board.getCommentCount()) @@ -37,11 +37,11 @@ public BoardInfo toBoardInfo(Board board, Integer boardHeartsCount, Boolean isLi } //rdb - public BoardInfo toBoardInfo(Board board, Boolean isLiked, Boolean isMine) { + public BoardInfo toBoardInfo(Board board, String writerNickname, Boolean isLiked, Boolean isMine) { return BoardInfo.builder() .boardId(board.getId()) .writerId(board.getWriter().getId()) - .writerNickname(board.getWriter().getNickname()) + .writerNickname(writerNickname) .content(board.getContent()) .heartCount(board.getHeartCount()) .commentCount(board.getCommentCount()) diff --git a/src/main/java/com/server/capple/domain/board/repository/BoardRepository.java b/src/main/java/com/server/capple/domain/board/repository/BoardRepository.java index 01fe885b..e74462ec 100644 --- a/src/main/java/com/server/capple/domain/board/repository/BoardRepository.java +++ b/src/main/java/com/server/capple/domain/board/repository/BoardRepository.java @@ -13,24 +13,27 @@ public interface BoardRepository extends JpaRepository { @Query("SELECT DISTINCT b AS board, " + "(CASE WHEN bh.isLiked = TRUE THEN TRUE ELSE FALSE END) AS isLike, " + - "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine " + + "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine, " + + "b.writer.nickname AS writerNickname " + "FROM Board b " + "LEFT JOIN BoardHeart bh ON b = bh.board AND bh.member = :member " + - "WHERE (:boardType IS NULL OR b.boardType = :boardType) AND b.id <= :lastIndex") - Slice findBoardInfosByMemberAndBoardTypeAndIdIsLessThanEqual(Member member, BoardType boardType, Long lastIndex, Pageable pageable); + "WHERE (:boardType IS NULL OR b.boardType = :boardType) AND (b.id < :lastIndex OR :lastIndex IS NULL)") + Slice findBoardInfosByMemberAndBoardTypeAndIdIsLessThan(Member member, BoardType boardType, Long lastIndex, Pageable pageable); @Query("SELECT DISTINCT b AS board, " + "(CASE WHEN bh.isLiked = TRUE THEN TRUE ELSE FALSE END) AS isLike, " + - "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine " + + "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine, " + + "b.writer.nickname AS writerNickname " + "FROM Board b " + "LEFT JOIN BoardHeart bh ON b = bh.board AND bh.member = :member " + - "WHERE b.id <= :lastIndex AND b.content LIKE %:keyword% AND b.boardType = 0") //FREETYPE = 0 - Slice findBoardInfosByMemberAndKeywordAndIdIsLessThanEqual(Member member, String keyword, Long lastIndex, Pageable pageable); + "WHERE (b.id < :lastIndex OR :lastIndex IS NULL) AND b.content LIKE %:keyword% AND b.boardType = 0") //FREETYPE = 0 + Slice findBoardInfosByMemberAndKeywordAndIdIsLessThan(Member member, String keyword, Long lastIndex, Pageable pageable); @Query("SELECT b AS board, " + "(CASE WHEN bh.isLiked = TRUE THEN TRUE ELSE FALSE END) AS isLike, " + - "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine " + + "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine, " + + "b.writer.nickname AS writerNickname " + "FROM Board b " + "LEFT JOIN BoardHeart bh ON b = bh.board AND bh.member = :member " + "WHERE b.id = :boardId") @@ -38,10 +41,11 @@ public interface BoardRepository extends JpaRepository { //redis 성능 테스트용 @Query("SELECT DISTINCT b AS board, " + - "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine " + + "(CASE WHEN b.writer = :member THEN TRUE ELSE FALSE END) AS isMine, " + + "b.writer.nickname AS writerNickname " + "FROM Board b " + - "WHERE (:boardType IS NULL OR b.boardType = :boardType) AND b.id <= :lastIndex") - Slice findBoardInfosForRedisAndIdIsLessThanEqual(Member member, BoardType boardType, Long lastIndex, Pageable pageable); + "WHERE (:boardType IS NULL OR b.boardType = :boardType) AND (b.id < :lastIndex OR :lastIndex IS NULL)") + Slice findBoardInfosForRedisAndIdIsLessThan(Member member, BoardType boardType, Long lastIndex, Pageable pageable); @Query("SELECT COUNT(b) FROM Board b") Integer getBoardCount(); diff --git a/src/main/java/com/server/capple/domain/board/service/BoardServiceImpl.java b/src/main/java/com/server/capple/domain/board/service/BoardServiceImpl.java index e7924c05..18f27272 100644 --- a/src/main/java/com/server/capple/domain/board/service/BoardServiceImpl.java +++ b/src/main/java/com/server/capple/domain/board/service/BoardServiceImpl.java @@ -61,12 +61,12 @@ public BoardId updateBoard(Member member, Long boardId, String content) { } public SliceResponse getBoardsByBoardType(Member member, BoardType boardType, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); - Slice sliceBoardInfos = boardRepository.findBoardInfosByMemberAndBoardTypeAndIdIsLessThanEqual(member, boardType, lastIndex, pageable); - lastIndex = getLastIndexFromBoardInfoInterface(lastIndex, sliceBoardInfos); + Slice sliceBoardInfos = boardRepository.findBoardInfosByMemberAndBoardTypeAndIdIsLessThan(member, boardType, lastIndex, pageable); + lastIndex = getLastIndexFromBoardInfoInterface(sliceBoardInfos); return SliceResponse.toSliceResponse(sliceBoardInfos, sliceBoardInfos.getContent().stream().map(sliceBoardInfo -> boardMapper.toBoardInfo( sliceBoardInfo.getBoard(), + sliceBoardInfo.getWriterNickname(), sliceBoardInfo.getIsLike(), sliceBoardInfo.getIsMine())) .toList(), lastIndex.toString(), boardCountService.getBoardCount() @@ -75,12 +75,12 @@ public SliceResponse getBoardsByBoardType(Member member, BoardType bo @Override public SliceResponse searchBoardsByKeyword(Member member, String keyword, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); - Slice sliceBoardInfos = boardRepository.findBoardInfosByMemberAndKeywordAndIdIsLessThanEqual(member, keyword, lastIndex, pageable); - lastIndex = getLastIndexFromBoardInfoInterface(lastIndex, sliceBoardInfos); + Slice sliceBoardInfos = boardRepository.findBoardInfosByMemberAndKeywordAndIdIsLessThan(member, keyword, lastIndex, pageable); + lastIndex = getLastIndexFromBoardInfoInterface(sliceBoardInfos); return SliceResponse.toSliceResponse(sliceBoardInfos, sliceBoardInfos.getContent().stream().map(sliceBoardInfo -> boardMapper.toBoardInfo( sliceBoardInfo.getBoard(), + sliceBoardInfo.getWriterNickname(), sliceBoardInfo.getIsLike(), sliceBoardInfo.getIsMine())) .toList(), lastIndex.toString(), null @@ -92,14 +92,14 @@ public SliceResponse searchBoardsByKeyword(Member member, String keyw */ @Override public SliceResponse getBoardsByBoardTypeWithRedis(Member member, BoardType boardType, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); - Slice sliceBoardInfos = boardRepository.findBoardInfosForRedisAndIdIsLessThanEqual(member, boardType, lastIndex, pageable); - lastIndex = getLastIndexFromBoardInfoInterface(lastIndex, sliceBoardInfos); + Slice sliceBoardInfos = boardRepository.findBoardInfosForRedisAndIdIsLessThan(member, boardType, lastIndex, pageable); + lastIndex = getLastIndexFromBoardInfoInterface(sliceBoardInfos); return SliceResponse.toSliceResponse(sliceBoardInfos, sliceBoardInfos.getContent().stream().map(sliceBoardInfo -> { int heartCount = boardHeartRedisRepository.getBoardHeartsCount(sliceBoardInfo.getBoard().getId()); boolean isLiked = boardHeartRedisRepository.isMemberLikedBoard(member.getId(), sliceBoardInfo.getBoard().getId()); return boardMapper.toBoardInfo( sliceBoardInfo.getBoard(), + sliceBoardInfo.getWriterNickname(), heartCount, isLiked, sliceBoardInfo.getIsMine()); @@ -113,6 +113,7 @@ public BoardInfo getBoard(Member member, Long boardId) { return boardMapper.toBoardInfo( boardInfo.getBoard(), + boardInfo.getWriterNickname(), boardInfo.getIsLike(), boardInfo.getIsMine() ); @@ -170,13 +171,9 @@ public void handleBoardCreatedEvent() { boardCountService.updateBoardCount(); } - private Long getLastIndex(Long lastIndex) { - lastIndex = lastIndex == null ? Long.MAX_VALUE : lastIndex; - return lastIndex; - } - - private Long getLastIndexFromBoardInfoInterface(Long lastIndex, Slice sliceBoardInfos) { - lastIndex = lastIndex == Long.MAX_VALUE ? sliceBoardInfos.stream().map(BoardInfoInterface::getBoard).map(Board::getId).max(Long::compareTo).get() : lastIndex; - return lastIndex; + private Long getLastIndexFromBoardInfoInterface(Slice sliceBoardInfos) { + if(sliceBoardInfos.hasContent()) + return sliceBoardInfos.stream().map(BoardInfoInterface::getBoard).map(Board::getId).min(Long::compareTo).get(); + return -1L; } } diff --git a/src/main/java/com/server/capple/domain/boardComment/controller/BoardCommentController.java b/src/main/java/com/server/capple/domain/boardComment/controller/BoardCommentController.java index 09ac4448..b3cdff44 100644 --- a/src/main/java/com/server/capple/domain/boardComment/controller/BoardCommentController.java +++ b/src/main/java/com/server/capple/domain/boardComment/controller/BoardCommentController.java @@ -54,14 +54,13 @@ public BaseResponse heartBoardComment(@AuthMember Membe return BaseResponse.onSuccess(boardCommentService.toggleBoardCommentHeart(member, commentId)); } - @Operation(summary = "게시글 댓글 리스트 조회 API", description = " 게시글 댓글 리스트 조회 API 입니다. pathVariable 으로 boardId를 주세요.") + @Operation(summary = "게시글 댓글 리스트 조회 API", description = " 게시글 댓글 리스트 조회 API 입니다. pathVariable 으로 boardId를 주세요.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @GetMapping("/{boardId}") public BaseResponse> getBoardCommentInfos(@AuthMember Member member, @PathVariable(value = "boardId") Long boardId, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { - return BaseResponse.onSuccess(boardCommentService.getBoardCommentInfos(member,boardId, threshold, PageRequest.of(pageNumber,pageSize, Sort.by(Sort.Direction.ASC, "createdAt")))); + return BaseResponse.onSuccess(boardCommentService.getBoardCommentInfos(member,boardId, lastIndex, PageRequest.of(0,pageSize, Sort.by(Sort.Direction.ASC, "createdAt")))); } } diff --git a/src/main/java/com/server/capple/domain/boardComment/repository/BoardCommentRepository.java b/src/main/java/com/server/capple/domain/boardComment/repository/BoardCommentRepository.java index 71cd5e90..f0a59796 100644 --- a/src/main/java/com/server/capple/domain/boardComment/repository/BoardCommentRepository.java +++ b/src/main/java/com/server/capple/domain/boardComment/repository/BoardCommentRepository.java @@ -14,6 +14,6 @@ public interface BoardCommentRepository extends JpaRepository findBoardCommentInfosByMemberAndBoardIdAndIdIsLessThanEqual(Member member, Long boardId, Long lastIndex, Pageable pageable); + "WHERE bc.board.id = :boardId AND (bc.id > :lastIndex OR :lastIndex IS NULL)") + Slice findBoardCommentInfosByMemberAndBoardIdAndIdIsGreaterThan(Member member, Long boardId, Long lastIndex, Pageable pageable); } diff --git a/src/main/java/com/server/capple/domain/boardComment/service/BoardCommentServiceImpl.java b/src/main/java/com/server/capple/domain/boardComment/service/BoardCommentServiceImpl.java index aa62eeac..afa8d95f 100644 --- a/src/main/java/com/server/capple/domain/boardComment/service/BoardCommentServiceImpl.java +++ b/src/main/java/com/server/capple/domain/boardComment/service/BoardCommentServiceImpl.java @@ -98,8 +98,8 @@ public ToggleBoardCommentHeart toggleBoardCommentHeart(Member member, Long board @Override public SliceResponse getBoardCommentInfos(Member member, Long boardId, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); - Slice sliceBoardCommentInfos = boardCommentRepository.findBoardCommentInfosByMemberAndBoardIdAndIdIsLessThanEqual(member, boardId, lastIndex, pageable); + Slice sliceBoardCommentInfos = boardCommentRepository.findBoardCommentInfosByMemberAndBoardIdAndIdIsGreaterThan(member, boardId, lastIndex, pageable); + lastIndex = getLastIndexFromBoardCommentInfoInterface(sliceBoardCommentInfos); return SliceResponse.toSliceResponse(sliceBoardCommentInfos, sliceBoardCommentInfos.getContent().stream().map(sliceBoardCommentInfo -> boardCommentMapper.toBoardCommentInfo( sliceBoardCommentInfo.getBoardComment(), @@ -120,13 +120,9 @@ public BoardComment findBoardComment(Long commentId) { () -> new RestApiException(CommentErrorCode.COMMENT_NOT_FOUND)); } - private Long getLastIndex(Long lastIndex) { - return lastIndex == null ? Long.MAX_VALUE : lastIndex; - } - - private Long getLastIndexFromBoardCommentInfoInterface(Long lastIndex, Slice sliceBoardCommentInfos) { - if(sliceBoardCommentInfos.hasContent() && lastIndex == Long.MAX_VALUE) + private Long getLastIndexFromBoardCommentInfoInterface(Slice sliceBoardCommentInfos) { + if(sliceBoardCommentInfos.hasContent()) return sliceBoardCommentInfos.stream().map(BoardCommentInfoInterface::getBoardComment).map(BoardComment::getId).max(Long::compareTo).get(); - return lastIndex; + return Long.MAX_VALUE; } } diff --git a/src/main/java/com/server/capple/domain/notifiaction/controller/NotificationController.java b/src/main/java/com/server/capple/domain/notifiaction/controller/NotificationController.java index e39880c3..3ec0f279 100644 --- a/src/main/java/com/server/capple/domain/notifiaction/controller/NotificationController.java +++ b/src/main/java/com/server/capple/domain/notifiaction/controller/NotificationController.java @@ -24,13 +24,13 @@ public class NotificationController { private final NotificationService notificationService; - @Operation(summary = "알림 리스트 조회 API", description = "API를 호출한 사용자가 받은 알림 리스트를 조회합니다. 알림은 최신순으로 정렬되어 반환됩니다.") + @Operation(summary = "알림 리스트 조회 API", description = "API를 호출한 사용자가 받은 알림 리스트를 조회합니다. 알림은 최신순으로 정렬되어 반환됩니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @GetMapping public BaseResponse> getNotifications( @AuthMember Member member, - @Parameter(description = "Pull to Refresh 후 마지막 index") - @RequestParam(required = false) Long threshold, - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { - return BaseResponse.onSuccess(notificationService.getNotifications(member, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); + @Parameter(description = "이전 조회의 마지막 index") + @RequestParam(required = false, name = "threshold") Long lastIndex, + @RequestParam(defaultValue = "1000", required = false) Integer pageSize) { + return BaseResponse.onSuccess(notificationService.getNotifications(member, lastIndex, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "createdAt")))); } } diff --git a/src/main/java/com/server/capple/domain/notifiaction/repository/NotificationRepository.java b/src/main/java/com/server/capple/domain/notifiaction/repository/NotificationRepository.java index 232dc374..bf0082f6 100644 --- a/src/main/java/com/server/capple/domain/notifiaction/repository/NotificationRepository.java +++ b/src/main/java/com/server/capple/domain/notifiaction/repository/NotificationRepository.java @@ -3,17 +3,19 @@ import com.server.capple.domain.notifiaction.entity.Notification; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; +import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import java.time.LocalDateTime; public interface NotificationRepository extends JpaRepository { + @EntityGraph(attributePaths = {"notificationLog"}) @Query("select " + "n " + "from Notification n " + "where " + - "n.id <= :lastIndex AND " + + "(n.id < :lastIndex OR :lastIndex IS NULL) AND " + "(" + "n.memberId = :memberId " + "OR " + diff --git a/src/main/java/com/server/capple/domain/notifiaction/service/NotificationServiceImpl.java b/src/main/java/com/server/capple/domain/notifiaction/service/NotificationServiceImpl.java index 4612e113..f64a475d 100644 --- a/src/main/java/com/server/capple/domain/notifiaction/service/NotificationServiceImpl.java +++ b/src/main/java/com/server/capple/domain/notifiaction/service/NotificationServiceImpl.java @@ -135,9 +135,8 @@ public void sendLiveQuestionCloseNotification(Question question) { @Override public SliceResponse getNotifications(Member member, Long lastIndex, Pageable pageable) { - lastIndex = getLastIndex(lastIndex); Slice notifications = notificationRepository.findByMemberId(member.getId(), lastIndex, pageable); - lastIndex = getLastIndexFromNotification(lastIndex, notifications); + lastIndex = getLastIndexFromNotification(notifications); return notificationMapper.toNotificationInfoSlice(notifications, lastIndex); } @@ -147,13 +146,9 @@ public void deleteNotificationsByCreatedAtBefore(LocalDateTime targetTime) { notificationRepository.deleteNotificationsByCreatedAtBefore(targetTime); } - private long getLastIndex(Long lastIndex) { - return lastIndex == null ? Long.MAX_VALUE : lastIndex; - } - - private Long getLastIndexFromNotification(Long lastIndex, Slice notifications) { - if(notifications.hasContent() && lastIndex == Long.MAX_VALUE) - return notifications.stream().map(Notification::getId).max(Long::compareTo).get(); - return lastIndex; + private Long getLastIndexFromNotification(Slice notifications) { + if(notifications.hasContent()) + return notifications.stream().map(Notification::getId).min(Long::compareTo).get(); + return -1L; } } diff --git a/src/main/java/com/server/capple/domain/question/controller/QuestionController.java b/src/main/java/com/server/capple/domain/question/controller/QuestionController.java index 86c033cf..86f210e4 100644 --- a/src/main/java/com/server/capple/domain/question/controller/QuestionController.java +++ b/src/main/java/com/server/capple/domain/question/controller/QuestionController.java @@ -37,19 +37,18 @@ private BaseResponse getMainQuestion(@AuthMember Member member) return BaseResponse.onSuccess(questionService.getMainQuestion(member)); } - @Operation(summary = "모든 질문 조회 API", description = "모든 질문을 조회합니다.") + @Operation(summary = "모든 질문 조회 API", description = "모든 질문을 조회합니다.
**첫 번째 조회 시 threshold를 비워 보내고, 이후 조회 시 앞선 조회의 반환값으로 받은 threshold를 보내주세요.**") @ApiResponses(value = { @ApiResponse(responseCode = "COMMON200", description = "성공"), }) @GetMapping private BaseResponse> getQuestions( @AuthMember Member member, - @Parameter(description = "최근의 Pull to Refresh 시각") - @RequestParam(required = false) LocalDateTime threshold, - @RequestParam(defaultValue = "0", required = false) Integer pageNumber, + @Parameter(description = "이전 조회의 마지막 데이터의 시각") + @RequestParam(required = false, name = "threshold") LocalDateTime lastDateTime, @RequestParam(defaultValue = "1000", required = false) Integer pageSize ) { - return BaseResponse.onSuccess(questionService.getQuestions(member, threshold, PageRequest.of(pageNumber, pageSize, Sort.by(Sort.Direction.DESC, "livedAt")))); + return BaseResponse.onSuccess(questionService.getQuestions(member, lastDateTime, PageRequest.of(0, pageSize, Sort.by(Sort.Direction.DESC, "livedAt")))); } @Operation(summary = "질문 좋아요/취소 API", description = " 질문 좋아요/취소 API 입니다." + diff --git a/src/main/java/com/server/capple/domain/question/repository/QuestionRepository.java b/src/main/java/com/server/capple/domain/question/repository/QuestionRepository.java index c70312a7..9569728e 100644 --- a/src/main/java/com/server/capple/domain/question/repository/QuestionRepository.java +++ b/src/main/java/com/server/capple/domain/question/repository/QuestionRepository.java @@ -26,8 +26,8 @@ public interface QuestionRepository extends JpaRepository { @Query("SELECT q AS question, (a IS NOT NULL) AS isAnsweredByMember " + "FROM Question q LEFT JOIN Answer a ON q = a.question AND a.deletedAt is NULL AND a.member = :member " + - "WHERE (q.questionStatus = 'OLD' OR q.questionStatus = 'LIVE') AND q.livedAt <= :thresholdDate") - Slice findAllByLivedAtBefore(@Param("member") Member member, @Param("thresholdDate") LocalDateTime thresholdDate, Pageable pageable); + "WHERE (q.questionStatus = 'OLD' OR q.questionStatus = 'LIVE') AND q.livedAt < :lastDateTime") + Slice findQuestionsByLivedAtBefore(@Param("member") Member member, @Param("lastDateTime") LocalDateTime lastDateTime, Pageable pageable); @Query("SELECT COUNT(q) FROM Question q WHERE q.questionStatus = 'OLD' OR q.questionStatus = 'LIVE'") Integer getLiveOrOldQuestionCount(); diff --git a/src/main/java/com/server/capple/domain/question/service/QuestionService.java b/src/main/java/com/server/capple/domain/question/service/QuestionService.java index c9bd746f..5e725aa0 100644 --- a/src/main/java/com/server/capple/domain/question/service/QuestionService.java +++ b/src/main/java/com/server/capple/domain/question/service/QuestionService.java @@ -15,7 +15,7 @@ public interface QuestionService { QuestionSummary getMainQuestion(Member member); - SliceResponse getQuestions(Member member, LocalDateTime thresholdDate, Pageable pageable); + SliceResponse getQuestions(Member member, LocalDateTime lastDateTime, Pageable pageable); QuestionResponse.QuestionToggleHeart toggleQuestionHeart(Member member, Long questionId); } diff --git a/src/main/java/com/server/capple/domain/question/service/QuestionServiceImpl.java b/src/main/java/com/server/capple/domain/question/service/QuestionServiceImpl.java index 95c8bf96..3d2b55ee 100644 --- a/src/main/java/com/server/capple/domain/question/service/QuestionServiceImpl.java +++ b/src/main/java/com/server/capple/domain/question/service/QuestionServiceImpl.java @@ -48,12 +48,13 @@ public QuestionSummary getMainQuestion(Member member) { } @Override - public SliceResponse getQuestions(Member member, LocalDateTime thresholdDate, Pageable pageable) { - thresholdDate = getThresholdDate(thresholdDate); - Slice questionSlice = questionRepository.findAllByLivedAtBefore(member, thresholdDate, pageable); + public SliceResponse getQuestions(Member member, LocalDateTime lastDateTime, Pageable pageable) { + lastDateTime = getThresholdDate(lastDateTime); + Slice questionSlice = questionRepository.findQuestionsByLivedAtBefore(member, lastDateTime, pageable); + lastDateTime = getThresholdDateFromQuestionInfoInterface(questionSlice); return SliceResponse.toSliceResponse(questionSlice, questionSlice.getContent().stream() .map(questionInfoInterface -> questionMapper.toQuestionInfo(questionInfoInterface.getQuestion(), questionInfoInterface.getIsAnsweredByMember()) - ).toList(), thresholdDate.toString(), questionCountService.getLiveOrOldQuestionCount()); + ).toList(), lastDateTime.toString(), questionCountService.getLiveOrOldQuestionCount()); } @Override @@ -67,4 +68,10 @@ public QuestionResponse.QuestionToggleHeart toggleQuestionHeart(Member member, L private LocalDateTime getThresholdDate(LocalDateTime thresholdDate) { return thresholdDate == null ? LocalDateTime.now() : thresholdDate; } + + private LocalDateTime getThresholdDateFromQuestionInfoInterface(Slice questionSlice) { + if(questionSlice.hasContent()) + return questionSlice.stream().map(QuestionInfoInterface::getQuestion).map(Question::getLivedAt).min(LocalDateTime::compareTo).get(); + return LocalDateTime.parse("0000-01-01T00:00:00"); + } } diff --git a/src/main/java/com/server/capple/global/common/SliceResponse.java b/src/main/java/com/server/capple/global/common/SliceResponse.java index a128d57d..1e55447f 100644 --- a/src/main/java/com/server/capple/global/common/SliceResponse.java +++ b/src/main/java/com/server/capple/global/common/SliceResponse.java @@ -11,31 +11,25 @@ @NoArgsConstructor public class SliceResponse { Integer total; - int number; int size; List content; int numberOfElements; String threshold; - boolean hasPrevious; boolean hasNext; public SliceResponse(Slice sliceObject) { - number = sliceObject.getNumber(); size = sliceObject.getSize(); content = sliceObject.getContent(); numberOfElements = sliceObject.getNumberOfElements(); - hasPrevious = sliceObject.hasPrevious(); hasNext = sliceObject.hasNext(); } @Builder - public SliceResponse(int number, int size, List content, int numberOfElements, String threshold, boolean hasPrevious, boolean hasNext, Integer total) { - this.number = number; + public SliceResponse(int size, List content, int numberOfElements, String threshold, boolean hasNext, Integer total) { this.size = size; this.content = content; this.numberOfElements = numberOfElements; this.threshold = threshold; - this.hasPrevious = hasPrevious; this.hasNext = hasNext; this.total = total; } @@ -46,12 +40,10 @@ public SliceResponse(int number, int size, List content, int numberOfElements */ public static SliceResponse toSliceResponse(Slice

sliceObject, List content, String threshold, Integer total) { return SliceResponse.builder() - .number(sliceObject.getNumber()) .size(sliceObject.getSize()) .content(content) .numberOfElements(sliceObject.getNumberOfElements()) .threshold(threshold) - .hasPrevious(sliceObject.hasPrevious()) .hasNext(sliceObject.hasNext()) .total(total) .build(); diff --git a/src/test/java/com/server/capple/domain/boardComment/controller/BoardCommentControllerTest.java b/src/test/java/com/server/capple/domain/boardComment/controller/BoardCommentControllerTest.java index fe5066f9..75e94421 100644 --- a/src/test/java/com/server/capple/domain/boardComment/controller/BoardCommentControllerTest.java +++ b/src/test/java/com/server/capple/domain/boardComment/controller/BoardCommentControllerTest.java @@ -149,7 +149,6 @@ public void getBoardCommentInfosTest() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.code").value("COMMON200")) .andExpect(jsonPath("$.message").value("요청에 성공하였습니다.")) - .andExpect(jsonPath("$.result.number").value(0)) .andExpect(jsonPath("$.result.size").value(10)) .andExpect(jsonPath("$.result.numberOfElements").value(1)) .andExpect(jsonPath("$.result.content[0].boardCommentId").value(1L)) diff --git a/src/test/java/com/server/capple/domain/boardComment/service/BoardCommentServiceTest.java b/src/test/java/com/server/capple/domain/boardComment/service/BoardCommentServiceTest.java index f1db1687..e304e5bf 100644 --- a/src/test/java/com/server/capple/domain/boardComment/service/BoardCommentServiceTest.java +++ b/src/test/java/com/server/capple/domain/boardComment/service/BoardCommentServiceTest.java @@ -123,7 +123,6 @@ public void getBoardCommentsTest() { assertEquals(0, response.getContent().get(0).getHeartCount()); assertEquals(false, response.getContent().get(0).getIsLiked()); assertEquals(true, response.getContent().get(0).getIsMine()); - assertEquals(0, response.getNumber()); assertEquals(10, response.getSize()); assertEquals(1, response.getNumberOfElements()); } diff --git a/src/test/java/com/server/capple/support/ControllerTestConfig.java b/src/test/java/com/server/capple/support/ControllerTestConfig.java index d230d1c4..06df67f0 100644 --- a/src/test/java/com/server/capple/support/ControllerTestConfig.java +++ b/src/test/java/com/server/capple/support/ControllerTestConfig.java @@ -108,11 +108,9 @@ protected SliceResponse getSliceMemberAnswerInfos() { .build()); return SliceResponse.builder() - .number(0) .size(1000) .content(memberAnswerInfos) .numberOfElements(1) - .hasPrevious(FALSE) .hasNext(FALSE) .build(); } @@ -135,11 +133,9 @@ protected SliceResponse getSliceBoardCommentInfos() { return SliceResponse.builder() - .number(0) .size(10) .content(commentInfos) .numberOfElements(1) - .hasPrevious(false) .hasNext(true) .build(); }