fix: 공지사항 저장 반영

dev
Lim Jonguk 3 years ago
parent b9fa2d0fc7
commit bcec7df978

@ -1,6 +1,9 @@
package com.xit.biz.ctgy.repository; package com.xit.biz.ctgy.repository;
import com.xit.biz.ctgy.entity.MinInfoBoard680; 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.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -10,4 +13,6 @@ public interface IPublicBoardRepository extends JpaRepository<MinInfoBoard680, L
Long getInCodeByInBgubun(); Long getInCodeByInBgubun();
MinInfoBoard680 findByInCode(final Long inCode); MinInfoBoard680 findByInCode(final Long inCode);
Page<MinInfoBoard680> findAllByOrderByInCodeDesc(Example<MinInfoBoard680> example, Pageable pageable);
} }

@ -5,10 +5,7 @@ import com.xit.biz.ctgy.repository.IPublicBoardRepository;
import com.xit.biz.ctgy.service.IPublicBoardService; import com.xit.biz.ctgy.service.IPublicBoardService;
import com.xit.core.support.jpa.JpaUtil; import com.xit.core.support.jpa.JpaUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Example; import org.springframework.data.domain.*;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -22,13 +19,16 @@ public class PublicBoardService implements IPublicBoardService {
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Page<MinInfoBoard680> findAll(final MinInfoBoard680 entity, Pageable pageable) { public Page<MinInfoBoard680> 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 = JpaUtil.getPagingInfo(pageable);
// pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending())
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll()
.withMatcher("inTitle", contains()) .withMatcher("inTitle", contains())
.withMatcher("inName", contains()); .withMatcher("inName", contains());
Example<MinInfoBoard680> example = Example.of(entity, exampleMatcher); Example<MinInfoBoard680> example = Example.of(entity, exampleMatcher);
Page<MinInfoBoard680> page = repository.findAll(example, pageable); Page<MinInfoBoard680> page = repository.findAll(
example,
PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending()));
// List<CmmUser> userList = page.getContent(); // List<CmmUser> userList = page.getContent();
return page; return page;
} }

Loading…
Cancel
Save