diff --git a/src/main/java/nlib/cmm/service/NlibProperty.java b/src/main/java/nlib/cmm/service/NlibProperty.java index a538ba1d..8b0d0973 100644 --- a/src/main/java/nlib/cmm/service/NlibProperty.java +++ b/src/main/java/nlib/cmm/service/NlibProperty.java @@ -125,6 +125,14 @@ public class NlibProperty { return getProperty(name); } + public static String getString(String name, String defaultValue) { + String val = getProperty(name); + + if(StringUtil.isEmpty(val)) return defaultValue; + + return val; + } + /** * name 값을 키로하는 속성값을 정부형태로 리턴한다. * 만일 값이 부재이거나 정부값으로 적합하지 않을 경우, defaultValue를 리턴한다. diff --git a/src/main/java/nlib/cmm/service/NotificationService.java b/src/main/java/nlib/cmm/service/NotificationService.java index b1d02260..997e5009 100644 --- a/src/main/java/nlib/cmm/service/NotificationService.java +++ b/src/main/java/nlib/cmm/service/NotificationService.java @@ -16,6 +16,11 @@ public interface NotificationService public List listNotifications(NotificationVO notificationVO) throws Exception; + /** + * 사용자 알림 목록의 건수를 조회한다. + */ + public int countNotifications(String recvUserId) throws Exception; + /** * 읽지 않은 알림 건수를 조회한다. * diff --git a/src/main/java/nlib/cmm/service/PagingVO.java b/src/main/java/nlib/cmm/service/PagingVO.java index 3659ec46..d16e97c5 100644 --- a/src/main/java/nlib/cmm/service/PagingVO.java +++ b/src/main/java/nlib/cmm/service/PagingVO.java @@ -2,28 +2,55 @@ package nlib.cmm.service; public class PagingVO { - String pageIndex; /* 페이지 번호 */ - String pageSize; /* 페이지 크기 (1페이지당 보여줄 자료건수) */ - int totRecordCount; /* 총건수 */ + int pageIndex = 1; /* 페이지 번호 */ + int pageSize = NlibProperty.getInt("list.paging.page.size", 10); /* 페이지 크기 (1페이지당 보여줄 자료건수) */ + int totRecordCount; /* 총건수 */ - public String getPageIndex() { + public int getPageIndex() { return pageIndex; } - public void setPageIndex(String pageIndex) { + + public void setPageIndex(int pageIndex) { this.pageIndex = pageIndex; } - public String getPageSize() { + + public void setPageIndex(String sPageIndex) { + try { + pageIndex = Integer.parseInt(sPageIndex); + } catch(Exception e) { + pageIndex = 1; + } + } + + public int getPageSize() { return pageSize; } - public void setPageSize(String pageSize) { + + public void setPageSize(int pageSize) { this.pageSize = pageSize; } + + public void setPageSize(String sPageSize) { + try { + pageSize = Integer.parseInt(sPageSize); + } catch(Exception e) { + pageSize = NlibProperty.getInt("list.paging.page.size", 10); + } + } + public int getTotRecordCount() { return totRecordCount; } + public void setTotRecordCount(int totRecordCount) { this.totRecordCount = totRecordCount; } - + public int getPageStartRowNum() { + + if(pageIndex < 1) pageIndex = 1; + if(pageSize < 1) pageSize = 10; + + return ((pageIndex - 1) * pageSize); + } } diff --git a/src/main/java/nlib/cmm/service/impl/NotificationDAO.java b/src/main/java/nlib/cmm/service/impl/NotificationDAO.java index be2c16db..fc2da9da 100644 --- a/src/main/java/nlib/cmm/service/impl/NotificationDAO.java +++ b/src/main/java/nlib/cmm/service/impl/NotificationDAO.java @@ -48,6 +48,15 @@ public class NotificationDAO extends EgovComAbstractDAO { return selectList("NotificationDAO.listNotifications", searchNotificationVO); } + + /** + * 사용자 알림 목록의 건수를 조회한다. + */ + public int countNotifications(String recvUserId) throws Exception { + + return selectOne("NotificationDAO.countNotifications", recvUserId); + } + /* * 사용자가 확인하지 않은 알림 건수를 조회한다. */ diff --git a/src/main/java/nlib/cmm/service/impl/NotificationServiceImpl.java b/src/main/java/nlib/cmm/service/impl/NotificationServiceImpl.java index cbafa8b9..5bbd232e 100644 --- a/src/main/java/nlib/cmm/service/impl/NotificationServiceImpl.java +++ b/src/main/java/nlib/cmm/service/impl/NotificationServiceImpl.java @@ -32,6 +32,14 @@ public class NotificationServiceImpl implements NotificationService return notificationDAO.listNotifications(notificationVO); } + /** + * 사용자 알림 목록의 건수를 조회한다. + */ + public int countNotifications(String recvUserId) throws Exception { + + return notificationDAO.countNotifications(recvUserId); + } + /** * 읽지 않은 알림 건수를 조회한다. * diff --git a/src/main/java/nlib/cmm/web/NotificationController.java b/src/main/java/nlib/cmm/web/NotificationController.java index 3c62182c..0e348e37 100644 --- a/src/main/java/nlib/cmm/web/NotificationController.java +++ b/src/main/java/nlib/cmm/web/NotificationController.java @@ -123,8 +123,7 @@ public class NotificationController extends NlibCommonController { searchNotificationtVO.setRecvUserId(mbInfoId); List list = notificationService.listNotifications(searchNotificationtVO); - int totRecordCount = (list == null || list.get(0) == null) ? 0 : list.get(0).getTotCnt(); - searchNotificationtVO.setTotRecordCount(totRecordCount); + int totRecordCount = notificationService.countNotifications(mbInfoId); //------------------------------- // JSON변환 응답 처리 @@ -151,12 +150,16 @@ public class NotificationController extends NlibCommonController { public ResponseEntity selectNotificationAjax(HttpServletRequest req, Authentication authentication, @RequestBody Map paramMap) throws Exception { String notiId = paramMap.get("notiId"); // 알림ID + String pageIndex = paramMap.get("pageIndex"); + String pageSize = paramMap.get("pageSize"); log.debug("selectNotificationAjax > notiId = " + notiId); NotificationVO paramNotiVO = new NotificationVO(); paramNotiVO.setNotiId(notiId); paramNotiVO.setRecvUserId(getMbInfoId(req)); + paramNotiVO.setPageIndex(pageIndex); + paramNotiVO.setPageSize(pageSize); // 읽음처리 및 상세내용 조회 NotificationVO notiVO = notificationService.selectNotification(paramNotiVO); diff --git a/src/main/resources/egovframework/mapper/nlib/cmm/NotificationDAO_SQL.xml b/src/main/resources/egovframework/mapper/nlib/cmm/NotificationDAO_SQL.xml index e3fcfe73..50d68f5c 100644 --- a/src/main/resources/egovframework/mapper/nlib/cmm/NotificationDAO_SQL.xml +++ b/src/main/resources/egovframework/mapper/nlib/cmm/NotificationDAO_SQL.xml @@ -3,7 +3,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + + +