알림기능 개발 - 중간백업

This commit is contained in:
KNKIM 2021-09-06 18:08:50 +09:00
parent 2307034219
commit 31523be6d5
4 changed files with 116 additions and 17 deletions

View File

@ -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를 리턴한다.
*

View File

@ -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;
/**
* <pre>
* @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<String, String> paramMap, ModelMap model) {
@RequestMapping("/cmm/listAlerts.do")
public String listAlerts(
HttpServletRequest req,
@RequestParam Map<String, String> 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<AlertVO> 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<String> listAlertsAjax(HttpServletRequest req,
Authentication authentication, @RequestBody Map<String, String> 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<AlertVO> 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<String, Object> retMap = new HashMap<String, Object>();
retMap.put("data", list);
retMap.put("itemsCount", totRecordCount);
return makeResponseEntityJson(retMap);
}
}

View File

@ -16,6 +16,7 @@
<typeAlias alias="EgovMap" type="egovframework.rte.psl.dataaccess.util.EgovMap" />
<typeAlias alias="NlibLoginVO" type="nlib.user.service.NlibLoginVO" />
<typeAlias alias="SecUserVO" type="nlib.security.SecUserVO" />
<typeAlias alias="AlertVO" type="nlib.cmm.service.AlertVO" />
</typeAliases>
</configuration>

View File

@ -20,6 +20,7 @@
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/rent/listReservations.do';">예약</a></li>
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/rent/listRequestsForViewingItem.do';">열람요청</a></li>
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/collection/listInterests.do';">관심자료</a></li>
<li><a href="#" onclick="javascript:location.href='${pageContext.request.contextPath}/cmm/listAlerts.do';">알림</a></li>
<!-- 개발자용 메뉴 -->
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/sample/getSampleInfoForm.do';">통신API</a></li>
@ -28,6 +29,7 @@
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/system/reloadProperties.do';">프로퍼티갱신</a></li>
<li><a href="#" style="color:#FF5;" onclick="javascript:location.href='${pageContext.request.contextPath}/code/listCodes.do';">코드조회</a></li>
</ul>
<script type="text/javascript">
$(function() {