History paging
This commit is contained in:
parent
f1725b6f46
commit
27bb2798f0
|
@ -23,5 +23,5 @@ public interface HistoryDAO extends JpaRepository<History, Long> {
|
||||||
Page<History> findAllByProbe(Probe probe, Pageable pageable);
|
Page<History> findAllByProbe(Probe probe, Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}")
|
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}")
|
||||||
List<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type);
|
Page<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service("HistoryService")
|
@Service("HistoryService")
|
||||||
public class HistoryService {
|
public class HistoryService {
|
||||||
|
|
||||||
|
@ -27,8 +25,10 @@ public class HistoryService {
|
||||||
// return this.historyDAO.findAllByProbeOrderByIdDesc(probe);
|
// return this.historyDAO.findAllByProbeOrderByIdDesc(probe);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public List<History> readAllByProbeAndType(Probe probe, MetaHistoryType type) {
|
public Page<History> readAllByProbeAndType(Probe probe, MetaHistoryType type, int pageNo, int countPerPage) {
|
||||||
return this.historyDAO.findAllByProbeAndType(probe, type);
|
Pageable pageRequest =
|
||||||
|
new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id"));
|
||||||
|
return this.historyDAO.findAllByProbeAndType(probe, type, pageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<History> readAllByProbe(Probe probe, int pageNo, int countPerPage) {
|
public Page<History> readAllByProbe(Probe probe, int pageNo, int countPerPage) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.loafle.overflow.module.member.model.Member;
|
||||||
import com.loafle.overflow.module.meta.model.MetaHistoryType;
|
import com.loafle.overflow.module.meta.model.MetaHistoryType;
|
||||||
import com.loafle.overflow.module.probe.model.Probe;
|
import com.loafle.overflow.module.probe.model.Probe;
|
||||||
import com.loafle.overflow.spring.AppConfigTest;
|
import com.loafle.overflow.spring.AppConfigTest;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -13,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,12 +40,12 @@ public class HistoryServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
@Ignore
|
// @Ignore
|
||||||
public void readAllByProbeAndType() {
|
// public void readAllByProbeAndType() {
|
||||||
List<History> result = this.historyService.readAllByProbeAndType(new Probe(1), new MetaHistoryType(1));
|
// List<History> result = this.historyService.readAllByProbeAndType(new Probe(1), new MetaHistoryType(1));
|
||||||
Assert.assertNotNull(result);
|
// Assert.assertNotNull(result);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
// public void readAllByProbeWithPaging() {
|
// public void readAllByProbeWithPaging() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user