feat: 사용자 장바구니 초기화 기능 추가

main
thkim 2025-10-02 10:08:10 +09:00
parent 5d10ef2575
commit 396073a070
11 changed files with 243 additions and 5 deletions

View File

@ -19,6 +19,7 @@ import java.net.MalformedURLException;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.jfree.util.Log; import org.jfree.util.Log;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
@ -575,6 +576,28 @@ public class MapContorlController {
return "map/mapControl/deleteCart"; return "map/mapControl/deleteCart";
} }
@RequestMapping(value = "/map/delete-all-cart-list.do", method = RequestMethod.POST)
@ResponseBody
public JSONObject deleteAllCartList(ModelMap model, HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, Object> params) throws Exception {
JSONObject jSONOResponse = new JSONObject();
String userId = request.getSession().getAttribute("USERID").toString();
params.put("userId", userId);
mapControlService.deleteAllCartList(params);
System.out.println("\n--------------------------------------------------------------\n" +
request.getRequestURI() + " OUT:" +
"\n--------------------------------------------------------------\n" +
"jSONOResponse.toJSONString():[" + jSONOResponse.toJSONString() + "]\n" +
"\n--------------------------------------------------------------\n");
return jSONOResponse;
}
// 장바구니 관련 다운로드 // 장바구니 관련 다운로드
@RequestMapping(value = "/map/downloadCart.do", method = RequestMethod.GET) @RequestMapping(value = "/map/downloadCart.do", method = RequestMethod.GET)
public String downloadPurpose(ModelMap model, HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, Object> params) throws Exception { public String downloadPurpose(ModelMap model, HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, Object> params) throws Exception {

View File

@ -38,6 +38,8 @@ public interface MapControlMapper {
void deleteCart(Map<String, Object> params) throws Exception; void deleteCart(Map<String, Object> params) throws Exception;
void deleteAllCartList(Map<String, Object> params) throws Exception;
EgovMap selectWebCartUserId(Map<String, Object> params) throws Exception; EgovMap selectWebCartUserId(Map<String, Object> params) throws Exception;
EgovMap selectWebDownloadLog(Map<String, Object> params) throws Exception; EgovMap selectWebDownloadLog(Map<String, Object> params) throws Exception;

View File

@ -37,6 +37,8 @@ public interface MapControlService {
void deleteCart(Map<String, Object> params) throws Exception; void deleteCart(Map<String, Object> params) throws Exception;
void deleteAllCartList(Map<String, Object> params) throws Exception;
EgovMap selectWebDownloadLog(Map<String, Object> params) throws Exception; EgovMap selectWebDownloadLog(Map<String, Object> params) throws Exception;
EgovMap selectSichuInfoMiniDnLastPage(Map<String, Object> params) throws Exception; EgovMap selectSichuInfoMiniDnLastPage(Map<String, Object> params) throws Exception;

View File

@ -88,6 +88,11 @@ public class MapContorlServiceImpl implements MapControlService{
mapControlMapper.deleteCart(params); mapControlMapper.deleteCart(params);
} }
@Override
public void deleteAllCartList(Map<String, Object> params) throws Exception {
mapControlMapper.deleteAllCartList(params);
}
@Override @Override
public EgovMap selectWebCartUserId(Map<String, Object> params) throws Exception { public EgovMap selectWebCartUserId(Map<String, Object> params) throws Exception {
return mapControlMapper.selectWebCartUserId(params); return mapControlMapper.selectWebCartUserId(params);

View File

@ -444,6 +444,16 @@
</update> </update>
<delete id="deleteAllCartList">
<![CDATA[
DELETE
FROM
WEB_CART wc
WHERE
TRIM(wc.USERID) = #{userId}
]]>
</delete>
<select id="selectWebCartUserId" parameterType="map" resultType="egovMap"> <select id="selectWebCartUserId" parameterType="map" resultType="egovMap">
<![CDATA[ <![CDATA[
SELECT SELECT

View File

@ -247,8 +247,15 @@ function goPage(page) {
<td> <td>
<table width="100%" border=0> <table width="100%" border=0>
<tr> <tr>
<td height="19" valign="top"><img src="/body/map/download/image/btn_allselect.gif" onClick="javascript:allSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand"><img src="/images/menu04/spacer.gif" width="10" height="19"><img src="/body/map/download/image/btn_deselect.gif" onClick="javascript:allDeSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand"> <td height="19" valign="top">
<img src="/images/menu04/spacer.gif" width="10" height="19"><img src="/body/map/download/image/btn_download.gif" onClick="javascript:downloadNew('<c:out value='${params.cnt}'/>')" style="cursor: hand"></td> <img src="/body/map/download/image/btn_delete_all.gif" onClick="javascript:deleteAllCartList()" style="cursor: pointer">
<img src="/images/menu04/spacer.gif" width="10" height="19">
<img src="/body/map/download/image/btn_allselect.gif" onClick="javascript:allSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand">
<img src="/images/menu04/spacer.gif" width="10" height="19">
<img src="/body/map/download/image/btn_deselect.gif" onClick="javascript:allDeSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand">
<img src="/images/menu04/spacer.gif" width="10" height="19">
<img src="/body/map/download/image/btn_download.gif" onClick="javascript:downloadNew('<c:out value='${params.cnt}'/>')" style="cursor: hand">
</td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@ -17,6 +17,9 @@
<script src="${pageContext.request.contextPath}/js/jquery/jquery.min.js" <script src="${pageContext.request.contextPath}/js/jquery/jquery.min.js"
language=javascript></script> language=javascript></script>
<script language=JavaScript src="${pageContext.request.contextPath}/js/common/common.js"></script>
<script language=JavaScript src="${pageContext.request.contextPath}/js/common/myXhr.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" <meta name="viewport"
content="width=device-width,initial-scale=1.0,maximum-scale=1" /> content="width=device-width,initial-scale=1.0,maximum-scale=1" />

View File

@ -8,6 +8,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr"> <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<link rel="stylesheet" HREF="/css/style.css" type="text/css"> <link rel="stylesheet" HREF="/css/style.css" type="text/css">
<link href="/css/hn1.css" rel="stylesheet" type="text/css"> <link href="/css/hn1.css" rel="stylesheet" type="text/css">
<script language=JavaScript src="${pageContext.request.contextPath}/js/common/myXhr.js"></script>
<script src="${pageContext.request.contextPath}/js/map/main/left/left.js"></script> <script src="${pageContext.request.contextPath}/js/map/main/left/left.js"></script>
<script src="${pageContext.request.contextPath}/js/map/main/result.js"></script> <script src="${pageContext.request.contextPath}/js/map/main/result.js"></script>
<script src="/js/map/gis/lib/js/jquery-1.11.0.min.js"></script> <script src="/js/map/gis/lib/js/jquery-1.11.0.min.js"></script>
@ -291,7 +292,10 @@
<tr> <tr>
<td><table width="100%" border=0> <td><table width="100%" border=0>
<tr> <tr>
<td height="19" valign="top"><img src="/body/map/download/image/btn_allselect.gif" onClick="javascript:allSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand"><img src="/images/menu04/spacer.gif" width="10" height="19"><img src="/body/map/download/image/btn_deselect.gif" onClick="javascript:allDeSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand"> <td height="19" valign="top">
<img src="/body/map/download/image/btn_delete_all.gif" onClick="javascript:deleteAllCartList()" style="cursor: pointer">
<img src="/images/menu04/spacer.gif" width="10" height="19">
<img src="/body/map/download/image/btn_allselect.gif" onClick="javascript:allSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand"><img src="/images/menu04/spacer.gif" width="10" height="19"><img src="/body/map/download/image/btn_deselect.gif" onClick="javascript:allDeSelect('<c:out value='${params.cnt}'/>')" style="cursor: hand">
<img src="/images/menu04/spacer.gif" width="10" height="19"><img src="/body/map/download/image/btn_download.gif" onClick="javascript:downloadNew('<c:out value='${params.cnt}'/>')" style="cursor: hand"></td> <img src="/images/menu04/spacer.gif" width="10" height="19"><img src="/body/map/download/image/btn_download.gif" onClick="javascript:downloadNew('<c:out value='${params.cnt}'/>')" style="cursor: hand"></td>
</tr> </tr>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,169 @@
let xhr;
if(window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else {
// IE5, IE6 일때
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
function requesetGet(URL, callback, callbackParamAsJson) {
xhr.open('GET', URL, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const obj = JSON.parse(xhr.responseText);
} else if (xhr.readyState === 4) {
// 요청 실패 시 처리
console.error('요청 실패:', xhr.status);
}
};
xhr.send();
}
function requesetPost(URL, jsonData, callback, callbackParamAsJson) {
xhr.open('POST', URL, true);
xhr.setRequestHeader('Content-type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
// 요청 성공 시 처리
let result = JSON.parse(xhr.response);
console.log(result.resultCode)
console.log(xhr.responseText);
const obj = JSON.parse(xhr.responseText);
if( typeof callback !== 'undefined' ) {
callback(callbackParamAsJson);
}
if (obj.resultCode == 100) {
} else {
//alert(obj.message);
}
} else if (xhr.readyState === 4) {
// 요청 실패 시 처리
console.error('요청 실패:', xhr.status);
}
};
xhr.send(JSON.stringify(jsonData));
}
/**
* AJAX
*/
//일반적인 경우
function ajax(url, param, callback){
$.ajax({
'type': 'POST',
url: url,
// async: false, //전역변수 한것(일단 추가했음- 삭제가능)
data: param,
// success:eval(callback),
success:function(data){
eval(callback)(data);
},
error: function(xhr, status, error){
alert("error :ajax status:"+xhr.status+"\nerror:"+error+"\nerror message:"+xhr.responseText);
}
});
}
//파일첨부용
function ajaxSubmit(formId,url,param,callback){
eval($(formId)).ajaxSubmit({
url: url,
data: param,
success:eval(callback),
error: function(xhr, status, error){
alert("예외발생가 발생했습니다. 시스템관리자에게 확인바랍니다.");
}
});
}
//폼 서브밋
function formSubmit(formId) {
this.formId = isNull(formId) == true ? "commonForm" : formId;
this.url = "";
if(this.formId == "commonForm"){
$("#commonForm")[0].reset();
}
this.setUrl = function setUrl(url){
this.url = url;
};
this.addParam = function addParam(key, value){
$("#"+this.formId).append($("<input type='hidden' name='"+key+"' id='"+key+"' value='"+value+"' >"));
};
this.submit = function submit(){
var frm = $("#"+this.formId)[0];
frm.action = this.url;
frm.method = "post";
frm.submit();
};
}
//널값 검사
function isNull(str) {
if (str == null) return true;
if (str == "NaN") return true;
if (new String(str).valueOf() == "undefined") return true;
var chkStr = new String(str);
if( chkStr.valueOf() == "undefined" ) return true;
if (chkStr == null) return true;
if (chkStr.toString().length == 0 ) return true;
return false;
}
//브라우저 체크
function fnGetBrowser() {
var agt = navigator.userAgent.toLowerCase();
if (agt.indexOf("trident") != -1) {
return getIEVersion(agt); //'Internet Explorer';
}
if (agt.indexOf("chrome") != -1) return 'chrome';
if (agt.indexOf("opera") != -1) return 'opera';
if (agt.indexOf("firefox") != -1) return 'firefox';
if (agt.indexOf("safari") != -1) return 'safari';
}
//IE버전체크
function getIEVersion(agt) {
var iever="ie11";
var index = agt.indexOf("trident");
var len = "trident".length;
var ver =agt.substr(index+len+1,1);
//IE 8 = trident/4.0
//IE 9 = trident/5.0
//IE 10 = trident/6.0
if(ver==4) iever="ie8";
if(ver==5) iever="ie9";
if(ver==6) iever="ie10";
if(ver==7) iever="ie11";
return iever;
}
String.prototype.endsWith = function(str) {
if (this.length < str.length) { return false; }
return this.lastIndexOf(str) + str.length == this.length;
}
function XSSCheck(str, level) {
if (level == undefined || level == 0) {
str = str.replace(/\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-/g,"");
} else if (level != undefined && level == 1) {
str = str.replace(/\</g, "&lt;");
str = str.replace(/\>/g, "&gt;");
}
return str;
}

View File

@ -67,6 +67,19 @@ function download(mId, fName) {
downloadWin.focus(); downloadWin.focus();
} }
/** 장바구니 전체 데이터 삭제 * */
function deleteAllCartList() {
var callback = function() {
alert('장바구니의 모든 항목이 삭제되었습니다.');
location.reload();
};
if(confirm("장바구니의 모든 항목을 초기화하시겠습니까?")){
requesetPost('/map/delete-all-cart-list.do', null, callback, null);
}else{
}
}
/** 데이터 전체 선택 * */ /** 데이터 전체 선택 * */
function allSelect(totalCnt) { function allSelect(totalCnt) {