알림 페이징 처리 완료
This commit is contained in:
parent
e43b309322
commit
da08abfe5f
@ -125,6 +125,14 @@ public class NlibProperty {
|
|||||||
return getProperty(name);
|
return getProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getString(String name, String defaultValue) {
|
||||||
|
String val = getProperty(name);
|
||||||
|
|
||||||
|
if(StringUtil.isEmpty(val)) return defaultValue;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* name 값을 키로하는 속성값을 정부형태로 리턴한다.
|
* name 값을 키로하는 속성값을 정부형태로 리턴한다.
|
||||||
* 만일 값이 부재이거나 정부값으로 적합하지 않을 경우, defaultValue를 리턴한다.
|
* 만일 값이 부재이거나 정부값으로 적합하지 않을 경우, defaultValue를 리턴한다.
|
||||||
|
|||||||
@ -16,6 +16,11 @@ public interface NotificationService
|
|||||||
public List<NotificationVO> listNotifications(NotificationVO notificationVO) throws Exception;
|
public List<NotificationVO> listNotifications(NotificationVO notificationVO) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사용자 알림 목록의 건수를 조회한다.
|
||||||
|
*/
|
||||||
|
public int countNotifications(String recvUserId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 읽지 않은 알림 건수를 조회한다.
|
* 읽지 않은 알림 건수를 조회한다.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -2,28 +2,55 @@ package nlib.cmm.service;
|
|||||||
|
|
||||||
public class PagingVO {
|
public class PagingVO {
|
||||||
|
|
||||||
String pageIndex; /* 페이지 번호 */
|
int pageIndex = 1; /* 페이지 번호 */
|
||||||
String pageSize; /* 페이지 크기 (1페이지당 보여줄 자료건수) */
|
int pageSize = NlibProperty.getInt("list.paging.page.size", 10); /* 페이지 크기 (1페이지당 보여줄 자료건수) */
|
||||||
int totRecordCount; /* 총건수 */
|
int totRecordCount; /* 총건수 */
|
||||||
|
|
||||||
public String getPageIndex() {
|
public int getPageIndex() {
|
||||||
return pageIndex;
|
return pageIndex;
|
||||||
}
|
}
|
||||||
public void setPageIndex(String pageIndex) {
|
|
||||||
|
public void setPageIndex(int pageIndex) {
|
||||||
this.pageIndex = 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;
|
return pageSize;
|
||||||
}
|
}
|
||||||
public void setPageSize(String pageSize) {
|
|
||||||
|
public void setPageSize(int pageSize) {
|
||||||
this.pageSize = 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() {
|
public int getTotRecordCount() {
|
||||||
return totRecordCount;
|
return totRecordCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTotRecordCount(int totRecordCount) {
|
public void setTotRecordCount(int totRecordCount) {
|
||||||
this.totRecordCount = totRecordCount;
|
this.totRecordCount = totRecordCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPageStartRowNum() {
|
||||||
|
|
||||||
|
if(pageIndex < 1) pageIndex = 1;
|
||||||
|
if(pageSize < 1) pageSize = 10;
|
||||||
|
|
||||||
|
return ((pageIndex - 1) * pageSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,15 @@ public class NotificationDAO extends EgovComAbstractDAO {
|
|||||||
return selectList("NotificationDAO.listNotifications", searchNotificationVO);
|
return selectList("NotificationDAO.listNotifications", searchNotificationVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사용자 알림 목록의 건수를 조회한다.
|
||||||
|
*/
|
||||||
|
public int countNotifications(String recvUserId) throws Exception {
|
||||||
|
|
||||||
|
return selectOne("NotificationDAO.countNotifications", recvUserId);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 사용자가 확인하지 않은 알림 건수를 조회한다.
|
* 사용자가 확인하지 않은 알림 건수를 조회한다.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -32,6 +32,14 @@ public class NotificationServiceImpl implements NotificationService
|
|||||||
return notificationDAO.listNotifications(notificationVO);
|
return notificationDAO.listNotifications(notificationVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사용자 알림 목록의 건수를 조회한다.
|
||||||
|
*/
|
||||||
|
public int countNotifications(String recvUserId) throws Exception {
|
||||||
|
|
||||||
|
return notificationDAO.countNotifications(recvUserId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 읽지 않은 알림 건수를 조회한다.
|
* 읽지 않은 알림 건수를 조회한다.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -123,8 +123,7 @@ public class NotificationController extends NlibCommonController {
|
|||||||
searchNotificationtVO.setRecvUserId(mbInfoId);
|
searchNotificationtVO.setRecvUserId(mbInfoId);
|
||||||
List<NotificationVO> list = notificationService.listNotifications(searchNotificationtVO);
|
List<NotificationVO> list = notificationService.listNotifications(searchNotificationtVO);
|
||||||
|
|
||||||
int totRecordCount = (list == null || list.get(0) == null) ? 0 : list.get(0).getTotCnt();
|
int totRecordCount = notificationService.countNotifications(mbInfoId);
|
||||||
searchNotificationtVO.setTotRecordCount(totRecordCount);
|
|
||||||
|
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
// JSON변환 응답 처리
|
// JSON변환 응답 처리
|
||||||
@ -151,12 +150,16 @@ public class NotificationController extends NlibCommonController {
|
|||||||
public ResponseEntity<String> selectNotificationAjax(HttpServletRequest req, Authentication authentication, @RequestBody Map<String, String> paramMap) throws Exception {
|
public ResponseEntity<String> selectNotificationAjax(HttpServletRequest req, Authentication authentication, @RequestBody Map<String, String> paramMap) throws Exception {
|
||||||
|
|
||||||
String notiId = paramMap.get("notiId"); // 알림ID
|
String notiId = paramMap.get("notiId"); // 알림ID
|
||||||
|
String pageIndex = paramMap.get("pageIndex");
|
||||||
|
String pageSize = paramMap.get("pageSize");
|
||||||
|
|
||||||
log.debug("selectNotificationAjax > notiId = " + notiId);
|
log.debug("selectNotificationAjax > notiId = " + notiId);
|
||||||
|
|
||||||
NotificationVO paramNotiVO = new NotificationVO();
|
NotificationVO paramNotiVO = new NotificationVO();
|
||||||
paramNotiVO.setNotiId(notiId);
|
paramNotiVO.setNotiId(notiId);
|
||||||
paramNotiVO.setRecvUserId(getMbInfoId(req));
|
paramNotiVO.setRecvUserId(getMbInfoId(req));
|
||||||
|
paramNotiVO.setPageIndex(pageIndex);
|
||||||
|
paramNotiVO.setPageSize(pageSize);
|
||||||
|
|
||||||
// 읽음처리 및 상세내용 조회
|
// 읽음처리 및 상세내용 조회
|
||||||
NotificationVO notiVO = notificationService.selectNotification(paramNotiVO);
|
NotificationVO notiVO = notificationService.selectNotification(paramNotiVO);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="NotificationDAO">
|
<mapper namespace="NotificationDAO">
|
||||||
|
|
||||||
<select id="listNotifications" parameterType="NotificationVO" resultType="NotificationVO">
|
<select id="listNotifications_bk20210910" parameterType="NotificationVO" resultType="NotificationVO">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SELECT
|
SELECT
|
||||||
A.NOTI_ID
|
A.NOTI_ID
|
||||||
@ -27,6 +27,47 @@
|
|||||||
]]>
|
]]>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="listNotifications" parameterType="NotificationVO" resultType="NotificationVO">
|
||||||
|
<![CDATA[
|
||||||
|
SELECT
|
||||||
|
A.NOTI_ID
|
||||||
|
, A.RECV_USER_ID
|
||||||
|
, A.TITLE
|
||||||
|
, A.CONTENT
|
||||||
|
, A.NOTI_METHOD
|
||||||
|
, A.NOTI_TYPE_CD
|
||||||
|
, B.S_CODE_NM AS NOTI_TYPE_NM
|
||||||
|
, IF(A.READ_DD IS NULL, 'N', 'Y') AS READ_YN
|
||||||
|
, DATE_FORMAT(A.REG_DD, '%Y-%M-%D') AS REG_DD
|
||||||
|
, COUNT(A.NOTI_ID) OVER(PARTITION BY 1) AS TOT_CNT
|
||||||
|
FROM SM_NOTIFICATION A
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT S.NOTI_ID
|
||||||
|
FROM SM_NOTIFICATION S
|
||||||
|
WHERE S.RECV_USER_ID = #{recvUserId}
|
||||||
|
AND S.REG_DD > DATE_SUB(NOW(), INTERVAL 1 MONTH)
|
||||||
|
ORDER BY S.NOTI_ID DESC
|
||||||
|
LIMIT #{pageStartRowNum}, #{pageSize}
|
||||||
|
) AS A2
|
||||||
|
USING(NOTI_ID)
|
||||||
|
JOIN SM_CODE_S B
|
||||||
|
ON B.S_CODE_ID = A.NOTI_TYPE_CD
|
||||||
|
WHERE 1=1
|
||||||
|
AND B.L_CODE_ID = 'NOTI_TYPE_CD'
|
||||||
|
AND B.USE_YN = 'Y'
|
||||||
|
ORDER BY A.NOTI_ID DESC
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="countNotifications" parameterType="String" resultType="Integer">
|
||||||
|
<![CDATA[
|
||||||
|
SELECT COUNT(1)
|
||||||
|
FROM SM_NOTIFICATION A
|
||||||
|
WHERE A.RECV_USER_ID = #{recvUserId}
|
||||||
|
AND A.REG_DD > DATE_SUB(NOW(), INTERVAL 1 MONTH)
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="countUnreadNotification" parameterType="String" resultType="Integer">
|
<select id="countUnreadNotification" parameterType="String" resultType="Integer">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
SELECT COUNT(NOTI_ID) AS UNREAD_CNT
|
SELECT COUNT(NOTI_ID) AS UNREAD_CNT
|
||||||
|
|||||||
@ -3,33 +3,17 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|
||||||
<title>Insert title here</title>
|
<title>test</title>
|
||||||
|
|
||||||
|
|
||||||
<script src="/nlib/js/jquery/jquery.min.js"></script>
|
<script src="/nlib/js/jquery/jquery.min.js"></script>
|
||||||
<script src="/nlib/js/nlib.js"></script>
|
<script src="/nlib/js/nlib.js"></script>
|
||||||
|
|
||||||
<style>
|
|
||||||
p {
|
|
||||||
font-size: 5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
p span {
|
|
||||||
font-size: 5rem;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="para">
|
NLIB
|
||||||
가테스트1
|
|
||||||
<p>가테스트2
|
|
||||||
<span>R테스트 3</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user