From a6636e89677f4b858dd927f7650e477a54d39bac Mon Sep 17 00:00:00 2001 From: de123456sdf Date: Tue, 2 Jul 2024 02:42:58 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20sort=20=EC=A0=95=EB=A0=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinchulgwinong/domain/board/service/BoardService.java | 7 ++++--- .../domain/category/service/JobBoardCategoryService.java | 5 +++-- .../domain/jobBoard/service/JobBoardService.java | 5 +++-- .../sinchulgwinong/domain/scrap/service/ScrapService.java | 7 ++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/team9502/sinchulgwinong/domain/board/service/BoardService.java b/src/main/java/team9502/sinchulgwinong/domain/board/service/BoardService.java index 283e739..d2edde5 100644 --- a/src/main/java/team9502/sinchulgwinong/domain/board/service/BoardService.java +++ b/src/main/java/team9502/sinchulgwinong/domain/board/service/BoardService.java @@ -4,6 +4,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import team9502.sinchulgwinong.domain.board.dto.request.BoardRequestDTO; @@ -53,7 +54,7 @@ public BoardResponseDTO boardCreate(User user, BoardRequestDTO boardRequestDTO) @Transactional(readOnly = true) public BoardListResponseDTO getAllBoard(int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("boardId"))); Page boardPage = boardRepository.findAll(pageable); @@ -124,7 +125,7 @@ public void boardDelete(Long boardId, User user) { @Transactional(readOnly = true) public BoardListResponseDTO getAllMyBoard(User user, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("boardId"))); Page boardPage = boardRepository.findByUser_UserId(user.getUserId(), pageable); @@ -146,7 +147,7 @@ public BoardListResponseDTO getAllMyBoard(User user, int page, int size) { @Transactional(readOnly = true) public BoardListResponseDTO getAllFindBoards(String boardTitle, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("boardId"))); Page boardPage = boardRepository.findByBoardTitleContaining( boardTitle, pageable); diff --git a/src/main/java/team9502/sinchulgwinong/domain/category/service/JobBoardCategoryService.java b/src/main/java/team9502/sinchulgwinong/domain/category/service/JobBoardCategoryService.java index 8644f7d..74ece0d 100644 --- a/src/main/java/team9502/sinchulgwinong/domain/category/service/JobBoardCategoryService.java +++ b/src/main/java/team9502/sinchulgwinong/domain/category/service/JobBoardCategoryService.java @@ -4,6 +4,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import team9502.sinchulgwinong.domain.category.dto.request.JobCategoryRequestDTO; @@ -50,7 +51,7 @@ public Set getAllLocalityName(String regionName, String subRegionName) { public JobBoardListResponseDTO getAllLocalityCategory( JobLocalityCategoryRequestDTO jobLocalityCategoryRequestDTO, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("jobBoardId"))); Locality locality = localityRepository.findByRegionNameAndSubRegionNameAndLocalityName( jobLocalityCategoryRequestDTO.getRegionName(), @@ -87,7 +88,7 @@ public Set getAllMinorCategoryName(String minorCategoryName){ public JobBoardListResponseDTO getAllJobCategory( JobCategoryRequestDTO jobCategoryRequestDTO, int page, int size){ - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("jobBoardId"))); JobCategory jobCategory = jobCategoryRepository.findByMajorCategoryNameAndMinorCategoryName( diff --git a/src/main/java/team9502/sinchulgwinong/domain/jobBoard/service/JobBoardService.java b/src/main/java/team9502/sinchulgwinong/domain/jobBoard/service/JobBoardService.java index 40381eb..323dfdb 100644 --- a/src/main/java/team9502/sinchulgwinong/domain/jobBoard/service/JobBoardService.java +++ b/src/main/java/team9502/sinchulgwinong/domain/jobBoard/service/JobBoardService.java @@ -8,6 +8,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -166,7 +167,7 @@ public BoardImage saveImageBo(MultipartFile multipartFile, JobBoard jobBoard) { @Transactional(readOnly = true) public JobBoardListResponseDTO getAllJobBoards(int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("jobBoardId"))); Page jobBoardPage = jobBoardRepository.findAll(pageable); @@ -302,7 +303,7 @@ public void deleteJobBoard(Long cpUserId, Long jobBoardId) { @Transactional(readOnly = true) public JobBoardListResponseDTO getAllMyJobBoards(Long cpUserId, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("jobBoardId"))); Page jobBoardPage = jobBoardRepository.findByCompanyUser_CpUserId(cpUserId, pageable); diff --git a/src/main/java/team9502/sinchulgwinong/domain/scrap/service/ScrapService.java b/src/main/java/team9502/sinchulgwinong/domain/scrap/service/ScrapService.java index 371987e..0ff7d89 100644 --- a/src/main/java/team9502/sinchulgwinong/domain/scrap/service/ScrapService.java +++ b/src/main/java/team9502/sinchulgwinong/domain/scrap/service/ScrapService.java @@ -4,6 +4,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import team9502.sinchulgwinong.domain.board.dto.response.BoardListResponseDTO; @@ -70,7 +71,7 @@ public boolean scrapCreateBoard(Long boardId, User user) { @Transactional(readOnly = true) public BoardListResponseDTO getAllScraps(User user, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("scrapId"))); Page boardScrapPage = boardScrapsRepository.findByUser_UserId(user.getUserId(), pageable); @@ -120,7 +121,7 @@ public boolean scrapCreateJobBoard(Long jobBoardId, User user) { @Transactional(readOnly = true) public JobBoardListResponseDTO getAllJobBoards(User user, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("jobScrapId"))); Page jobScrapPage = jobScrapRepository.findByUser_UserId(user.getUserId(), pageable); @@ -168,7 +169,7 @@ public boolean cpUserScrapCreate(User user, Long cpUserId) { @Transactional(readOnly = true) public CpUserScrapListResponseDTO getAllCpUserScrap(User user, int page, int size) { - Pageable pageable = PageRequest.of(page, size); + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Order.desc("cpUserScrapId"))); Page cpUserScrapPage = cpUserScrapRepository.findByUser_UserId(user.getUserId(), pageable);