diff --git a/src/main/java/nlib/cmm/web/MainController.java b/src/main/java/nlib/cmm/web/MainController.java index ffaf7ad1..5639a214 100644 --- a/src/main/java/nlib/cmm/web/MainController.java +++ b/src/main/java/nlib/cmm/web/MainController.java @@ -14,7 +14,9 @@ import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import nlib.cmm.NlibCommonController; +import nlib.cmm.service.NlibProperty; import nlib.cmm.service.NotificationService; +import nlib.col.service.CartService; import nlib.user.service.NlibLoginVO; import nlib.util.StringUtil; @@ -48,6 +50,9 @@ public class MainController extends NlibCommonController { @Resource(name="notificationService") private NotificationService notificationService; + @Resource(name = "cartService") + private CartService cartService; + @RequestMapping( {"/index.do"} ) public String setContent( HttpServletRequest req, @@ -61,17 +66,50 @@ public class MainController extends NlibCommonController { log.debug((authentication == null ? "손님 메인 접속" : authentication.getName() + " 메인 접속")); + return "nlib/cmm/home"; + } + + @RequestMapping( {"/cmm/headerSubPart.do"} ) + public String headerSub( + HttpServletRequest request, + HttpServletResponse response, + Authentication authentication, + ModelMap model) throws Exception { + + // 캐쉬된 Reqeust 히스토리 삭제 + RequestCache cache = new HttpSessionRequestCache(); + cache.removeRequest(request, response); + + log.debug((authentication == null ? "손님 메인 접속" : authentication.getName() + " 메인 접속")); + + String mbInfoId = getMbInfoId(request); + + // 카트 건수 확인 + + // 카트 목록 가져오기 + int cartCnt = 0; + if(StringUtil.isEmpty(mbInfoId)) { + // 카트 건수 + cartCnt = cartService.countCartItemsFromCookie(request, response, "1"); + cartCnt += cartService.countCartItemsFromCookie(request, response, "2"); + } else { + cartCnt = cartService.countCartItems(mbInfoId, "0"); + } + // 알림 확인 - String mbInfoId = getMbInfoId(req); int unreadNotiCnt = 0; - if(!isAlerted(req) && StringUtil.isNotEmpty(mbInfoId)) { + if(StringUtil.isNotEmpty(mbInfoId)) { unreadNotiCnt = notificationService.countUnreadNotification(mbInfoId); - setAlerted(req, true); } + if(!isAlerted(request)) { + setAlerted(request, true); + } + + model.addAttribute("cartCnt", cartCnt); model.addAttribute("unreadNotiCnt", unreadNotiCnt); - return "nlib/cmm/home"; + return "nlib/cmm/headerSubPart"; } } \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/tiles/inc/header.jsp b/src/main/webapp/WEB-INF/tiles/inc/header.jsp index b16e2851..52658613 100644 --- a/src/main/webapp/WEB-INF/tiles/inc/header.jsp +++ b/src/main/webapp/WEB-INF/tiles/inc/header.jsp @@ -5,76 +5,4 @@ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> - -<% -String councilCd = (String)session.getAttribute("councilCd"); -String councilNm = (String)session.getAttribute("councilNm"); -%> - -