From f7ed5c6b1e792ba65f63d40cefb8f81d5a76322e Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Mon, 19 Aug 2024 09:40:10 +0900 Subject: [PATCH] =?UTF-8?q?setPagingInfo(..)=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foundation/web/AbstractController.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/cokr/xit/foundation/web/AbstractController.java b/src/main/java/cokr/xit/foundation/web/AbstractController.java index 731e265..86fa76b 100644 --- a/src/main/java/cokr/xit/foundation/web/AbstractController.java +++ b/src/main/java/cokr/xit/foundation/web/AbstractController.java @@ -173,24 +173,31 @@ public abstract class AbstractController extends AbstractBean { * @return ModelAndView */ protected ModelAndView setPagingInfo(ModelAndView mav, Collection collection, String prefix) { + Map map = null; if (collection instanceof BoundedList bounded) { - Map map = Map.of( + map = Map.of( "start", bounded.getStart(), + "dataSize", bounded.size(), "totalSize", bounded.getTotalSize(), - "fetchSize", bounded.getFetchSize() + "fetchSize", bounded.getFetchSize(), + "more", bounded.hasMore(), + "next", bounded.hasNext(), + "prev", bounded.hasPrevious() ); - mav.addObject(prefix + "List", bounded) - .addObject(prefix + "PagingInfo", map); } else { - Map map = Map.of( - "start", 0, - "totalSize", collection.size(), - "fetchSize", collection.size() - ); - mav.addObject(prefix + "List", collection) - .addObject(prefix + "PagingInfo", map); + map = Map.of( + "start", 0, + "dataSize", collection.size(), + "totalSize", collection.size(), + "fetchSize", collection.size(), + "more", false, + "next", false, + "prev", false + ); } - return mav; + return mav.addObject("prefix", prefix) + .addObject(prefix + "List", collection) + .addObject(prefix + "Paging", map); } /**한 번에 반환할 조회 결과의 수를 설정한다.