From bcec7df9786c9d52ab0f564f61cc5b2815ac30f5 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Wed, 30 Mar 2022 04:21:08 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/ctgy/repository/IPublicBoardRepository.java | 5 +++++ .../biz/ctgy/service/impl/PublicBoardService.java | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/xit/biz/ctgy/repository/IPublicBoardRepository.java b/src/main/java/com/xit/biz/ctgy/repository/IPublicBoardRepository.java index b8adbda..61d1bdc 100644 --- a/src/main/java/com/xit/biz/ctgy/repository/IPublicBoardRepository.java +++ b/src/main/java/com/xit/biz/ctgy/repository/IPublicBoardRepository.java @@ -1,6 +1,9 @@ package com.xit.biz.ctgy.repository; import com.xit.biz.ctgy.entity.MinInfoBoard680; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -10,4 +13,6 @@ public interface IPublicBoardRepository extends JpaRepository findAllByOrderByInCodeDesc(Example example, Pageable pageable); } diff --git a/src/main/java/com/xit/biz/ctgy/service/impl/PublicBoardService.java b/src/main/java/com/xit/biz/ctgy/service/impl/PublicBoardService.java index ab11923..3dce912 100644 --- a/src/main/java/com/xit/biz/ctgy/service/impl/PublicBoardService.java +++ b/src/main/java/com/xit/biz/ctgy/service/impl/PublicBoardService.java @@ -5,10 +5,7 @@ import com.xit.biz.ctgy.repository.IPublicBoardRepository; import com.xit.biz.ctgy.service.IPublicBoardService; import com.xit.core.support.jpa.JpaUtil; import lombok.AllArgsConstructor; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.ExampleMatcher; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -22,13 +19,16 @@ public class PublicBoardService implements IPublicBoardService { @Transactional(readOnly = true) public Page findAll(final MinInfoBoard680 entity, Pageable pageable) { - //Sort sort = Sort.by(Sort.Direction.ASC, "codeOrdr"); + // Sort sort = Sort.by(Sort.Direction.DESC, "inCode"); pageable = JpaUtil.getPagingInfo(pageable); + // pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending()) ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() .withMatcher("inTitle", contains()) .withMatcher("inName", contains()); Example example = Example.of(entity, exampleMatcher); - Page page = repository.findAll(example, pageable); + Page page = repository.findAll( + example, + PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending())); // List userList = page.getContent(); return page; }