diff --git a/server/src/main/java/com/yogit/server/block/service/BlockServiceImpl.java b/server/src/main/java/com/yogit/server/block/service/BlockServiceImpl.java index 16766a9..5d25268 100644 --- a/server/src/main/java/com/yogit/server/block/service/BlockServiceImpl.java +++ b/server/src/main/java/com/yogit/server/block/service/BlockServiceImpl.java @@ -30,7 +30,6 @@ public class BlockServiceImpl implements BlockService{ private final BlockRepository blockRepository; private final UserRepository userRepository; private final BoardRepository boardRepository; - private final BoardUserRepository boardUserRepository; private final TokenService tokenService; @Override diff --git a/server/src/main/java/com/yogit/server/board/controller/BoardController.java b/server/src/main/java/com/yogit/server/board/controller/BoardController.java index abf757b..e892260 100644 --- a/server/src/main/java/com/yogit/server/board/controller/BoardController.java +++ b/server/src/main/java/com/yogit/server/board/controller/BoardController.java @@ -172,7 +172,7 @@ public ApplicationResponse>> findBoardsByCategories(@R @ApiResponse(code = 4000 , message = "서버 오류입니다.") }) @PostMapping("/get/myclub") - public ApplicationResponse> findMyClubBoards(@RequestBody @Validated GetMyClubBoardsReq dto){ + public ApplicationResponse findMyClubBoards(@RequestBody @Validated GetMyClubBoardsReq dto){ return boardService.findMyClubBoards(dto); } diff --git a/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java b/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java index 6f1f8d6..7b5ab28 100644 --- a/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java +++ b/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java @@ -25,7 +25,7 @@ public interface BoardRepository extends JpaRepository { Page findAllBoardsByCategory(Pageable pageable, @Param("categoryId") Long categoryId); @Query("select b from Board b where b.status = 'ACTIVE' and b.host.id = :userId") - Slice findMyClubBoardsByUserId(Pageable pageable, @Param("userId") Long userId); + Page findMyClubBoardsByUserId(Pageable pageable, @Param("userId") Long userId); @Query("select b from Board b where b.status = 'ACTIVE' and b.host.id = :userId") List findBoardsByUserId(@Param("userId") Long userId); diff --git a/server/src/main/java/com/yogit/server/board/repository/BoardUserRepository.java b/server/src/main/java/com/yogit/server/board/repository/BoardUserRepository.java index d0c9211..daa85ad 100644 --- a/server/src/main/java/com/yogit/server/board/repository/BoardUserRepository.java +++ b/server/src/main/java/com/yogit/server/board/repository/BoardUserRepository.java @@ -1,6 +1,9 @@ package com.yogit.server.board.repository; import com.yogit.server.board.entity.BoardUser; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -17,7 +20,7 @@ public interface BoardUserRepository extends JpaRepository { Optional findByUserIdAndBoardId(@Param("userId") Long userId, @Param("boardId") Long boardId); @Query("select bu from BoardUser bu where bu.status = 'ACTIVE' and bu.user.id = :userId") - Slice findByUserId(@Param("userId") Long userId); + Page findByUserId(Pageable pageable, @Param("userId") Long userId); @Query("select bu from BoardUser bu where bu.status = 'ACTIVE' and bu.board.id = :boardId") List findAllByBoardId(@Param("boardId") Long boardId); diff --git a/server/src/main/java/com/yogit/server/board/service/BoardService.java b/server/src/main/java/com/yogit/server/board/service/BoardService.java index 505b099..75471ef 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardService.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardService.java @@ -22,7 +22,7 @@ public interface BoardService { ApplicationResponse>> findBoardsByCategories(GetBoardsByCategoriesReq getBoardsByCategoriesReq); - ApplicationResponse> findMyClubBoards(GetMyClubBoardsReq getMyClubBoardsReq); + ApplicationResponse findMyClubBoards(GetMyClubBoardsReq getMyClubBoardsReq); ApplicationResponse findBoard(GetBoardReq getBoardReq); diff --git a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java index 8964d9d..3435f41 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java @@ -245,7 +245,7 @@ public ApplicationResponse>> findAllBoards(GetAllBoard @Transactional(readOnly = true) @Override - public ApplicationResponse> findMyClubBoards(GetMyClubBoardsReq dto){ + public ApplicationResponse findMyClubBoards(GetMyClubBoardsReq dto){ tokenService.validateRefreshToken(dto.getUserId(), dto.getRefreshToken()); @@ -260,8 +260,8 @@ public ApplicationResponse> findMyClubBoards(GetMyClubBoard ); PageRequest pageRequest = PageRequest.of(cursor, PAGING_SIZE, sort); - Slice boards = null; - Slice boardUsers = null; + Page boards = null; + Page boardUsers = null; List res = null; /* 1.생성한 보드: Opened Club @@ -278,7 +278,7 @@ public ApplicationResponse> findMyClubBoards(GetMyClubBoard } } else if(dto.getMyClubType().equals(MyClubType.APPLIED_CLUB.toString())){ - boardUsers = boardUserRepository.findByUserId(dto.getUserId()); + boardUsers = boardUserRepository.findByUserId(pageRequest, dto.getUserId()); // System.out.println("보드 유저는?: "+ boardUsers); // 보드 res에 이미지uuid -> aws s3 url로 변환 @@ -291,7 +291,12 @@ else if(dto.getMyClubType().equals(MyClubType.APPLIED_CLUB.toString())){ } else{ throw new InvalidMyClubTypeException();} - return ApplicationResponse.ok(res); + if(dto.getMyClubType().equals(MyClubType.OPENED_CLUB.toString())){ + return ApplicationResponse.ok(GetAllBoardsByCategoryRes.toDto(res, boards.getTotalPages())); + } + else { + return ApplicationResponse.ok(GetAllBoardsByCategoryRes.toDto(res, boardUsers.getTotalPages())); + } }