공지사항/QnA : 문화원별 표출 처리, 카트 머징 : 테스트 및 보완
This commit is contained in:
parent
2e685876f1
commit
a0a9a90b8e
@ -94,4 +94,16 @@ public interface CartService
|
||||
*/
|
||||
public int saveCartItemsOfNonMember(String mbInfoId, HttpServletRequest request) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 쿠키 카트(비로그인 상태의 카트정보) 존재하는 경우, 해당 사용자 카트(DB)로 등록한 후, 쿠키 카트 삭제한다.
|
||||
*
|
||||
* @param mbInfoId
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int mergeCart(String mbInfoId, HttpServletRequest request, HttpServletResponse response) throws Exception;
|
||||
|
||||
}
|
||||
@ -12,6 +12,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import nlib.cmm.service.NlibProperty;
|
||||
import nlib.col.service.CartCookieVO;
|
||||
import nlib.col.service.CartService;
|
||||
import nlib.col.service.CollectionService;
|
||||
@ -46,7 +47,7 @@ public class CartServiceImpl implements CartService
|
||||
private static final Logger log = LoggerFactory.getLogger(CartServiceImpl.class);
|
||||
|
||||
// 비로그인회원의 카트정보 쿠키명
|
||||
public static final String CART_COOKIE_NAME = "_NLIB_COOKIE";
|
||||
public static final String CART_COOKIE_NAME = NlibProperty.getString("cart.cookie.name");
|
||||
|
||||
|
||||
@Resource(name="cartDAO")
|
||||
@ -71,17 +72,17 @@ public class CartServiceImpl implements CartService
|
||||
* (비로그인자용) 쿠키에서 카트 목록을 조회한다.
|
||||
*
|
||||
* @param request
|
||||
* @param cartDivCd
|
||||
* @param cartTypeCd
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<CollectionVO> listCartItemsFromCookie(HttpServletRequest request, HttpServletResponse response, String cartDivCd) throws Exception {
|
||||
public List<CollectionVO> listCartItemsFromCookie(HttpServletRequest request, HttpServletResponse response, String cartTypeCd) throws Exception {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if(cookies == null || cookies.length < 1) return null;
|
||||
|
||||
List<CollectionVO> list = new ArrayList<CollectionVO>();
|
||||
|
||||
String targetCookieName = CART_COOKIE_NAME + (cartDivCd == null || cartDivCd.equals("0") ? "" : cartDivCd);
|
||||
String targetCookieName = CART_COOKIE_NAME + (cartTypeCd == null || cartTypeCd.equals("0") ? "" : cartTypeCd);
|
||||
|
||||
for(Cookie cookie : cookies) {
|
||||
String cookieName = cookie.getName();
|
||||
@ -287,6 +288,8 @@ public class CartServiceImpl implements CartService
|
||||
*/
|
||||
public void setCookie(HttpServletResponse response, String name, String value) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setDomain(NlibProperty.getString("cart.cookie.domain"));
|
||||
cookie.setPath(NlibProperty.getString("cart.cookie.path"));
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
@ -534,4 +537,37 @@ public class CartServiceImpl implements CartService
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 쿠키 카트(비로그인 상태의 카트정보) 존재하는 경우, 해당 사용자 카트(DB)로 등록한 후, 쿠키 카트 삭제한다.
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int mergeCart(String mbInfoId, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
// 대출 카트
|
||||
String cartTypeCds[] = {"1", "2"};
|
||||
int mergeCnt = 0;
|
||||
|
||||
for(String cartTypeCd : cartTypeCds) {
|
||||
List<CollectionVO> list = listCartItemsFromCookie(request, response, cartTypeCd);
|
||||
if(list == null || list.size() < 1) continue;
|
||||
|
||||
for(CollectionVO item : list) {
|
||||
item.setCartTypeCd(cartTypeCd);
|
||||
item.setMbInfoId(mbInfoId);
|
||||
item.setRegId(mbInfoId);
|
||||
if(insertCartItem(item) != null) continue;
|
||||
mergeCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
// 쿠키 카트 정보 초기화
|
||||
setCookieCart(response, new CartCookieVO());
|
||||
|
||||
return mergeCnt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class CartController extends NlibCommonController
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/cart/listCartItems.do")
|
||||
@RequestMapping(value= {"/cart/listCartItems.do", "/login/listCartItems.do"})
|
||||
public String listCartItems(HttpServletRequest request, HttpServletResponse response, String message, String cartTypeCd, ModelMap model) throws Exception {
|
||||
|
||||
if(StringUtil.isEmpty(cartTypeCd)) cartTypeCd = "1"; // 대출 기본 설정
|
||||
@ -267,22 +267,19 @@ public class CartController extends NlibCommonController
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/cart/saveCartItemsOfNonMemberAjax")
|
||||
public String saveCartItemsOfNonMemberAjax(HttpServletRequest request, ModelMap model) throws Exception {
|
||||
@RequestMapping("/cart/mergeCartItemsAjax.do")
|
||||
public ResponseEntity<String> mergeCartItemsAjax(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws Exception {
|
||||
|
||||
String message = null;
|
||||
String mbInfoId = getMbInfoId(request);
|
||||
int resultCnt = 0;
|
||||
if(StringUtil.isEmpty(mbInfoId)) {
|
||||
message = "잘못된 접근입니다. 로그인 후, 이용가능합니다.";
|
||||
} else {
|
||||
resultCnt = cartService.saveCartItemsOfNonMember(mbInfoId, request);
|
||||
}
|
||||
int mergedCnt = 0;
|
||||
|
||||
model.addAttribute("message", message);
|
||||
model.addAttribute("resultCnt", resultCnt);
|
||||
if(StringUtil.isEmpty(mbInfoId)) mergedCnt = -1;
|
||||
else mergedCnt = cartService.mergeCart(mbInfoId, request, response);
|
||||
|
||||
return "nlib/col/saveCartItemsOfNonMember";
|
||||
HashMap<String, Object> retMap = new HashMap<String, Object>();
|
||||
retMap.put("mergedCnt", mergedCnt);
|
||||
|
||||
return makeResponseEntityJson(retMap);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
package nlib.user.web;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -10,7 +11,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
||||
@ -21,7 +21,6 @@ import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@ -29,8 +28,11 @@ import egovframework.com.ext.oauth.service.OAuthConfig;
|
||||
import egovframework.com.ext.oauth.service.OAuthLogin;
|
||||
import egovframework.com.ext.oauth.service.OAuthUniversalUser;
|
||||
import egovframework.com.ext.oauth.service.OAuthVO;
|
||||
import nlib.cmm.NlibCommonController;
|
||||
import nlib.cmm.service.NlibProperty;
|
||||
import nlib.cmm.session.SessionConfig;
|
||||
import nlib.col.service.CartService;
|
||||
import nlib.col.service.CollectionVO;
|
||||
import nlib.user.service.LoginService;
|
||||
import nlib.user.service.NlibLoginVO;
|
||||
import nlib.util.StringUtil;
|
||||
@ -61,7 +63,7 @@ import nlib.util.StringUtil;
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class LoginController {
|
||||
public class LoginController extends NlibCommonController {
|
||||
|
||||
public LoginController() {
|
||||
super();
|
||||
@ -87,6 +89,9 @@ public class LoginController {
|
||||
@Resource(name = "loginService")
|
||||
private LoginService loginService;
|
||||
|
||||
@Resource(name = "cartService")
|
||||
private CartService cartService;
|
||||
|
||||
|
||||
/**
|
||||
* 각 지방문화원 사이트에서 로그인을 위해서 최초 접속한다.
|
||||
@ -355,6 +360,7 @@ public class LoginController {
|
||||
model.addAttribute("message", StringUtil.encodeUrl("먼저 회원가입하신 후, 이용하여 주시기 바랍니다."));
|
||||
return "nlib/login/loginPreSet";
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
// 해당 처리기로 전환
|
||||
//-----------------------------------------------
|
||||
@ -376,28 +382,32 @@ public class LoginController {
|
||||
* ID, PW를 입력받아 로그인을 처리한다.
|
||||
* (스프링 시큐리티 로그인 수행)
|
||||
*
|
||||
* @param req
|
||||
* @param res
|
||||
* @param request
|
||||
* @param response
|
||||
* @param username
|
||||
* @param password
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/login/login.do")
|
||||
public String login(HttpServletRequest req, HttpServletResponse res,
|
||||
public String login(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestParam(required = false) String username, @RequestParam(required = false) String password,
|
||||
ModelMap model) {
|
||||
ModelMap model) throws Exception {
|
||||
|
||||
String loginResult = loginService.login(req, username, password);
|
||||
String loginResult = loginService.login(request, username, password);
|
||||
String redirectUrl = NlibProperty.getString("home.uri");
|
||||
|
||||
// 정상적으로 로그인된 경우
|
||||
if (StringUtil.isEmpty(loginResult)) {
|
||||
RequestCache cache = new HttpSessionRequestCache();
|
||||
SavedRequest savedRequest = cache.getRequest(req, res);
|
||||
SavedRequest savedRequest = cache.getRequest(request, response);
|
||||
if (savedRequest != null) {
|
||||
redirectUrl = savedRequest.getRedirectUrl();
|
||||
}
|
||||
|
||||
// 쿠키 카트(비로그인 상태의 카트정보) 존재하는 경우, 해당 사용자 카트(DB)로 등록한 후, 쿠키 카트 삭제
|
||||
//String mbInfoId = getMbInfoId(request);
|
||||
//cartService.mergeCart(mbInfoId, request, response);
|
||||
}
|
||||
// 로그인 실패
|
||||
else {
|
||||
@ -420,10 +430,10 @@ public class LoginController {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/login/loginCouncilSSO.do")
|
||||
@RequestMapping(value= {"/login/loginCouncilSSO.do"})
|
||||
public String loginCouncilSSO(
|
||||
HttpServletRequest req,
|
||||
HttpServletResponse res,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
HttpSession session,
|
||||
ModelMap model) throws Exception {
|
||||
|
||||
@ -439,10 +449,12 @@ public class LoginController {
|
||||
//-----------------------------------------------
|
||||
// 로그인 처리
|
||||
//-----------------------------------------------
|
||||
String loginResult = loginService.loginCouncilSSO(req, councilCd, oauthUser);
|
||||
String loginResult = loginService.loginCouncilSSO(request, councilCd, oauthUser);
|
||||
|
||||
// 정상 SNS 연동 로그인
|
||||
if(loginResult == null) {
|
||||
String mbInfoId = getMbInfoId(request);
|
||||
cartService.mergeCart(mbInfoId, request, response);
|
||||
SessionConfig.removeLoginInfo(jsessionId);
|
||||
// 세션에 설정된 redirect 주소 확인
|
||||
return "redirect:" + councilReturnUrl;
|
||||
|
||||
@ -154,3 +154,13 @@ auth.role.user = ROLE_USER
|
||||
auth.role.admin = ROLE_ADMIN
|
||||
# \uc2dc\uc2a4\ud15c\uad00\ub9ac\uc790
|
||||
auth.role.system = ROLE_SYSTEM
|
||||
|
||||
|
||||
#----------------------------------------
|
||||
# \uce74\ud2b8 \uad00\ub828
|
||||
#----------------------------------------
|
||||
# \ubbf8\ub85c\uadf8\uc778 \uc0ac\uc6a9\uc790\uc758 \uce74\ud2b8\uc815\ubcf4\uac00 \uc800\uc7a5\ub418\ub294 \ucfe0\ud0a4 \uc124\uc815 \ub3c4\uba54\uc778
|
||||
cart.cookie.domain = nculture.org
|
||||
# \ubbf8\ub85c\uadf8\uc778 \uc0ac\uc6a9\uc790\uc758 \uce74\ud2b8\uc815\ubcf4\uac00 \uc800\uc7a5\ub418\ub294 \ucfe0\ud0a4\uba85
|
||||
cart.cookie.name = _NLIB_CART_COOKIE
|
||||
cart.cookie.path = /
|
||||
|
||||
@ -300,6 +300,15 @@ function fn_changeCartItems(cartTypeCd, cartTypeNm) {
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<br>
|
||||
COOKIES :
|
||||
<script>
|
||||
document.write(document.cookie);
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
<title>서비스 이동중</title>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#frm").submit();
|
||||
//$("#frm").submit();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
@ -62,5 +62,11 @@ message : <input type="text" name="message" id="message" value="${message }" /><
|
||||
<input type="submit" value="계속" />
|
||||
</form>
|
||||
|
||||
<br>
|
||||
COOKIES :
|
||||
<script>
|
||||
document.write(document.cookie);
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
<%
|
||||
/**
|
||||
* <pre>
|
||||
@ -30,8 +31,10 @@
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
|
||||
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
|
||||
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
|
||||
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
|
||||
<%@ taglib prefix="validator"
|
||||
uri="http://www.springmodules.org/tags/commons-validator"%>
|
||||
<%@ taglib prefix="sec"
|
||||
uri="http://www.springframework.org/security/tags"%>
|
||||
|
||||
<c:set var="pageTitle">대출관리</c:set>
|
||||
|
||||
@ -41,9 +44,12 @@
|
||||
<title>${pageTitle}</title>
|
||||
|
||||
<!-- GRID -->
|
||||
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.css" />
|
||||
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid-theme.css" />
|
||||
<script src="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.js"></script>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.css" />
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid-theme.css" />
|
||||
<script
|
||||
src="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.js"></script>
|
||||
|
||||
<script type="text/javaScript" language="javascript">
|
||||
|
||||
@ -83,11 +89,9 @@ window.onload = function() {
|
||||
dataType: "json",
|
||||
data: JSON.stringify(inputData),
|
||||
}).done(function(response){
|
||||
<%
|
||||
// 그리드 데이터 예시 :
|
||||
<%// 그리드 데이터 예시 :
|
||||
// (1) 페이징 클라이언트에서 수행하는 경우(pageloading = false) : [{ "articleNo": 1, "articleType": "01" }, { "articleNo": 2, "articleType": "02" }]
|
||||
// (2) 페이징 서버에서 수행하는 경우(pageloading = true) : {data: [{...}], itemsCount: 255}
|
||||
%>
|
||||
// (2) 페이징 서버에서 수행하는 경우(pageloading = true) : {data: [{...}], itemsCount: 255}%>
|
||||
var retObj = JSON.parse(response);
|
||||
|
||||
if(retObj.data == null) {
|
||||
@ -159,38 +163,44 @@ function fn_search(bookLtRvStatusCd) {
|
||||
|
||||
<h1>${pageTitle }</h1>
|
||||
|
||||
<br /> 메시지 :
|
||||
<span style="color: red !important;">${message }</span>
|
||||
<br />
|
||||
<br />
|
||||
메시지 : <span style="color:red !important;">${message }</span>
|
||||
<br/><br/>
|
||||
|
||||
<form name="frm" id="frm" method="post">
|
||||
총 <span name="totRecordCount" id="totRecordCount">0</span> 건
|
||||
|
||||
|
||||
bookLtRvStatusCd <input type="text" name="bookLtRvStatusCd" id="bookLtRvStatusCd" value="${bookLtRvStatusCd }" title="대출상태구분" />
|
||||
<br>
|
||||
|
||||
<a href="javascript:void(0);" onclick="fn_search('')"> <span id="bookLtRvStatusCd" style="color:red">전체</span></a> |
|
||||
<a href="javascript:void(0);" onclick="fn_search('A')"><span id="bookLtRvStatusCdA" style="color:red">신청/예약</span></a> |
|
||||
<a href="javascript:void(0);" onclick="fn_search('C')"><span id="bookLtRvStatusCdC" style="color:red">취소</span></a> |
|
||||
<a href="javascript:void(0);" onclick="fn_search('W')"><span id="bookLtRvStatusCdW" style="color:red">대출중</span></a> |
|
||||
<a href="javascript:void(0);" onclick="fn_search('R')"><span id="bookLtRvStatusCdR" style="color:red">반납</span></a> |
|
||||
<a href="javascript:void(0);" onclick="fn_search('P')"><span id="bookLtRvStatusCdP" style="color:red">연체</span></a>
|
||||
|
||||
|
||||
|
||||
<select name="mngOrgCd" id="mngOrgCd" title="문화원 선택">
|
||||
bookLtRvStatusCd <input type="text" name="bookLtRvStatusCd"
|
||||
id="bookLtRvStatusCd" value="${bookLtRvStatusCd }" title="대출상태구분" />
|
||||
<br> <a href="javascript:void(0);" onclick="fn_search('')"> <span
|
||||
id="bookLtRvStatusCd" style="color: red">전체</span></a> | <a
|
||||
href="javascript:void(0);" onclick="fn_search('A')"><span
|
||||
id="bookLtRvStatusCdA" style="color: red">신청/예약</span></a> | <a
|
||||
href="javascript:void(0);" onclick="fn_search('C')"><span
|
||||
id="bookLtRvStatusCdC" style="color: red">취소</span></a> | <a
|
||||
href="javascript:void(0);" onclick="fn_search('W')"><span
|
||||
id="bookLtRvStatusCdW" style="color: red">대출중</span></a> | <a
|
||||
href="javascript:void(0);" onclick="fn_search('R')"><span
|
||||
id="bookLtRvStatusCdR" style="color: red">반납</span></a> | <a
|
||||
href="javascript:void(0);" onclick="fn_search('P')"><span
|
||||
id="bookLtRvStatusCdP" style="color: red">연체</span></a> <select
|
||||
name="mngOrgCd" id="mngOrgCd" title="문화원 선택">
|
||||
<option value="">전체</option>
|
||||
<c:forEach var="orgItem" items="${rentMngOrgList}" varStatus="status">
|
||||
<option value="<c:out value="${orgItem.mngOrgCd }" />" <c:if test="${orgItem.mngOrgCd == mngOrgCd }">selected</c:if> ><c:out value="${orgItem.mngOrgNm }" /></option>
|
||||
<option value="<c:out value="${orgItem.mngOrgCd }" />"
|
||||
<c:if test="${orgItem.mngOrgCd == mngOrgCd }">selected</c:if>><c:out
|
||||
value="${orgItem.mngOrgNm }" /></option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
|
||||
pageIndex <input type="text" name="pageIndex" id="pageIndex" title="페이지번호" value="${pageIndex }" size="5" maxlength="5" />
|
||||
</select> pageIndex <input type="text" name="pageIndex" id="pageIndex"
|
||||
title="페이지번호" value="${pageIndex }" size="5" maxlength="5" />
|
||||
|
||||
<div id="jsGrid" name="jsGrid" style="height: 100%"></div>
|
||||
<input type="button" value="대출 취소목록" onClick="location.href='${pageContext.request.contextPath}/rent/listCanceledRentItems.do'">
|
||||
<input type="button" value="반납 연기" onClick="location.href='${pageContext.request.contextPath}/rent/listPostpones.do'">
|
||||
<input type="button" value="대출 취소목록"
|
||||
onClick="location.href='${pageContext.request.contextPath}/rent/listCanceledRentItems.do'">
|
||||
<input type="button" value="반납 연기"
|
||||
onClick="location.href='${pageContext.request.contextPath}/rent/listPostpones.do'">
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user