diff --git a/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java b/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java index 4f335ed..c037b3c 100644 --- a/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java +++ b/src/main/java/com/loafle/overflow/module/history/dao/HistoryDAO.java @@ -24,4 +24,7 @@ public interface HistoryDAO extends JpaRepository { Page findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable); Page findAllByDomain(@Param("domain") Domain domain, Pageable pageRequest); + + @Query("SELECT h FROM History h WHERE h.domain.id = :#{#domain.id} and h.type.id = :#{#type.id}") + Page findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest); } diff --git a/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java b/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java index 7f147fb..5d096de 100644 --- a/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java +++ b/src/main/java/com/loafle/overflow/module/history/service/HistoryService.java @@ -44,4 +44,10 @@ public class HistoryService { new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id")); return this.historyDAO.findAllByDomain(domain, pageRequest); } + + public Page readAllByDomainAndType(Domain domain, MetaHistoryType type, int pageNo, int countPerPage) { + Pageable pageRequest = + new PageRequest(pageNo, countPerPage, new Sort(Sort.Direction.DESC, "id")); + return this.historyDAO.findAllByDomainAndType(domain, type, pageRequest); + } }