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; }