diff --git a/src/main/java/nlib/cmm/NlibCommonController.java b/src/main/java/nlib/cmm/NlibCommonController.java index 57002657..708d1fb3 100644 --- a/src/main/java/nlib/cmm/NlibCommonController.java +++ b/src/main/java/nlib/cmm/NlibCommonController.java @@ -54,7 +54,7 @@ import nlib.util.StringUtil; */ public class NlibCommonController { - private static final Logger log = LoggerFactory.getLogger(BoardController.class); + private static final Logger log = LoggerFactory.getLogger(NlibCommonController.class); @Resource(name = "loginService") private LoginService _loginService; @@ -79,6 +79,24 @@ public class NlibCommonController { return (NlibLoginVO)authentication.getPrincipal(); } + /** + * 사용자로그인정보 ID를 리턴한다. + * 로그인하지 않은 경우, null을 리턴한다. + * + * @param request + * @return + */ + public String getMbInfoId(HttpServletRequest request) { + + Authentication auth = (Authentication)request.getUserPrincipal(); + if(auth == null || !auth.isAuthenticated()) return null; + + NlibLoginVO loginVO = (NlibLoginVO)auth.getPrincipal(); + if(loginVO == null || StringUtil.isEmpty(loginVO.getMbInfoId())) return null; + + return loginVO.getMbInfoId(); + } + /** * 스프링 시큐리티 Authentication를 통해서 사용자로그인정보 SecUserVO를 리턴한다. * diff --git a/src/main/java/nlib/cmm/web/AlertController.java b/src/main/java/nlib/cmm/web/AlertController.java index 3a4e4420..67f2e069 100644 --- a/src/main/java/nlib/cmm/web/AlertController.java +++ b/src/main/java/nlib/cmm/web/AlertController.java @@ -1,24 +1,38 @@ package nlib.cmm.web; +import java.util.HashMap; +import java.util.List; import java.util.Map; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.Authentication; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; import nlib.cmm.NlibCommonController; -import nlib.cmm.exception.ErrorMessage; +import nlib.cmm.service.AlertService; +import nlib.cmm.service.AlertVO; +import nlib.cmm.service.NlibProperty; +import nlib.restful.service.DataApiReqVO; +import nlib.restful.service.DataApiResVO; +import nlib.util.StringUtil; /** *
* @Class Name : AlertController.java
*
- * @Description : 각종 처리 결과/오류 안내관련 공통 컨트롤러 클래스
+ * @Description : 사용자 홈페이지 알림 안내 컨트롤러
*
*
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
@@ -28,35 +42,99 @@ import nlib.cmm.exception.ErrorMessage;
* @ ------------ -------- ---------------------------
* @ 수정일 수정자 수정내용
* @ ------------ -------- ---------------------------
- * @ 2021. 7. 29. KNKIM 최초 생성
+ * @ 2021. 9. 6. KNKIM 최초 생성
*
*
* @author 이씨플라자 * DIGITALSHIP KNKIM
- * @since 2021. 7. 29.
+ * @since 2021. 9. 6.
* @version 1.0
*
*/
@Controller
public class AlertController extends NlibCommonController {
+
+ private static final Logger log = LoggerFactory.getLogger(AlertController.class);
+
+ static final String DEFUALT_PAGE_SIZE = NlibProperty.getProperty("list.paging.page.size");
+
+ @Resource(name="alertService")
+ private AlertService alertService;
- private static final Logger log = LoggerFactory.getLogger(SystemController.class);
/**
- * NLIB Property 재로드 작업을 요청한다.
+ * 알림 목록 조회한다.
*
- * @param authentication
- * @param model
+ * @param req
* @return
*/
- @RequestMapping( {"/alert/showError.do"} )
- public String showError(HttpServletRequest req, @RequestParam Map paramMap, ModelMap model) {
+ @RequestMapping("/cmm/listAlerts.do")
+ public String listAlerts(
+ HttpServletRequest req,
+ @RequestParam Map paramMap,
+ ModelMap model
+ ) throws Exception {
- addParamFromInputFlash(paramMap, req);
- model.addAttribute("code", paramMap.get("errorCode"));
- model.addAttribute("message", paramMap.get("errorMessage"));
- model.addAttribute("goBackUrl", paramMap.get("goBackUrl"));
+ String mbInfoId = getMbInfoId(req);
+ String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1");
+ String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE);
- return "nlib/cmm/common";
+ log.debug("listAlerts > pageIndex = " + pageIndex);
+ log.debug("listAlerts > pageSize = " + pageSize);
+
+ AlertVO searchAlertVO = new AlertVO();
+ searchAlertVO.setPageIndex(pageIndex);
+ searchAlertVO.setPageSize(pageSize);
+ searchAlertVO.setMbInfoId(mbInfoId);
+ List list = alertService.listAlerts(searchAlertVO);
+
+ int totRecordCount = (list == null || list.get(0) == null) ? 0 : list.get(0).getTotCnt();
+ searchAlertVO.setTotRecordCount(totRecordCount);
+
+ model.addAttribute("alertList", list);
+ model.addAttribute("searchAlertVO", searchAlertVO);
+
+ return "nlib/cmm/listAlerts";
}
-
+
+ /**
+ * 알림 목록 조회한다.
+ *
+ * @param req
+ * @return
+ */
+ @RequestMapping(value="/cmm/listAlertsAjax.do")
+ public ResponseEntity listAlertsAjax(HttpServletRequest req,
+ Authentication authentication, @RequestBody Map paramMap) throws Exception {
+
+ String mbInfoId = getMbInfoId(req);
+ String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1");
+ String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE);
+
+ log.debug("listAlertsAjax > pageIndex = " + pageIndex);
+ log.debug("listAlertsAjax > pageSize = " + pageSize);
+
+
+ AlertVO searchAlertVO = new AlertVO();
+ searchAlertVO.setPageIndex(pageIndex);
+ searchAlertVO.setPageSize(pageSize);
+ searchAlertVO.setMbInfoId(mbInfoId);
+ List list = alertService.listAlerts(searchAlertVO);
+
+ int totRecordCount = (list == null || list.get(0) == null) ? 0 : list.get(0).getTotCnt();
+ searchAlertVO.setTotRecordCount(totRecordCount);
+
+ //-------------------------------
+ // JSON변환 응답 처리
+ //-------------------------------
+ // JS-GRID 페이징 처리를 포함한 응답값 처리
+ // {data: [{...}],
+ // itemsCount: 255
+ // }
+ HashMap retMap = new HashMap();
+ retMap.put("data", list);
+ retMap.put("itemsCount", totRecordCount);
+
+ return makeResponseEntityJson(retMap);
+ }
+
}
\ No newline at end of file
diff --git a/src/main/resources/egovframework/mapper/config/mapper-config.xml b/src/main/resources/egovframework/mapper/config/mapper-config.xml
index 4cca8ee2..e0ec797c 100644
--- a/src/main/resources/egovframework/mapper/config/mapper-config.xml
+++ b/src/main/resources/egovframework/mapper/config/mapper-config.xml
@@ -16,6 +16,7 @@
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/tiles/inc/menu.jsp b/src/main/webapp/WEB-INF/tiles/inc/menu.jsp
index ab5b57a4..323c0ff7 100644
--- a/src/main/webapp/WEB-INF/tiles/inc/menu.jsp
+++ b/src/main/webapp/WEB-INF/tiles/inc/menu.jsp
@@ -20,6 +20,7 @@
예약
열람요청
관심자료
+ 알림
통신API
@@ -28,6 +29,7 @@
프로퍼티갱신
코드조회
+