코드관리 페이지 완료
parent
3bf841d809
commit
ea1cb9335c
|
|
@ -53,21 +53,15 @@ public class adminController {
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/insertCode")
|
@PostMapping("/insertCode")
|
||||||
public CommonCode insertCommonCode(CommonCode commonCode){
|
public CommonCode insertCommonCode(CommonCode commonCode){
|
||||||
commonCodeService.insertCommonCode(commonCode);
|
commonCodeService.insertCommonCode(commonCode);
|
||||||
return commonCode;
|
return commonCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/deleteCode")
|
@PutMapping(value = "/deleteCode")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public int deleteCommonCode(
|
public int deleteCommonCode(@RequestBody List<CommonCode> codeList) {
|
||||||
// @RequestBody HashMap<String, Object> map
|
|
||||||
// @RequestBody CommonCode code
|
|
||||||
@RequestBody List<CommonCode> codeList
|
|
||||||
) {
|
|
||||||
// return map.size();
|
|
||||||
// return code.getCodeSq();
|
|
||||||
commonCodeService.updateCommonCode(codeList);
|
commonCodeService.updateCommonCode(codeList);
|
||||||
return codeList.size();
|
return codeList.size();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,5 @@ import java.util.List;
|
||||||
|
|
||||||
public interface CommonCodeRepository extends JpaRepository<CommonCode, Integer> {
|
public interface CommonCodeRepository extends JpaRepository<CommonCode, Integer> {
|
||||||
|
|
||||||
List<CommonCode> findByCategory(String category);
|
List<CommonCode> findByCategoryAndIsDeleted(String category, String isDeleted);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class CommonCodeService {
|
||||||
return commonCodeMapper.selectCommonCodeCategory(commonCode);
|
return commonCodeMapper.selectCommonCodeCategory(commonCode);
|
||||||
}
|
}
|
||||||
public List<CommonCode> selectCommonCodeValue(CommonCode commonCode) {
|
public List<CommonCode> selectCommonCodeValue(CommonCode commonCode) {
|
||||||
return commonCodeRepository.findByCategory(commonCode.getCategory());
|
return commonCodeRepository.findByCategoryAndIsDeleted(commonCode.getCategory(), "N");
|
||||||
}
|
}
|
||||||
public void insertCommonCode(CommonCode commonCode) {
|
public void insertCommonCode(CommonCode commonCode) {
|
||||||
commonCodeRepository.save(commonCode);
|
commonCodeRepository.save(commonCode);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ $(document).on('click', '#saveBtn', function (){
|
||||||
if(confirm("저장하시겠습니까?")){
|
if(confirm("저장하시겠습니까?")){
|
||||||
const formData = new FormData($("#commonCodeForm")[0]);
|
const formData = new FormData($("#commonCodeForm")[0]);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'PUT',
|
type : 'POST',
|
||||||
data : formData,
|
data : formData,
|
||||||
url : "/admin/insertCode",
|
url : "/admin/insertCode",
|
||||||
processData: false,
|
processData: false,
|
||||||
|
|
@ -67,25 +67,33 @@ $(document).on('click', '#deleteCommonCodeBtn', function (){
|
||||||
const codeList = [];
|
const codeList = [];
|
||||||
$(".valueCheckBox:checked").each(function (idx, el){
|
$(".valueCheckBox:checked").each(function (idx, el){
|
||||||
codeList.push({});
|
codeList.push({});
|
||||||
codeList[idx].codeSq = Number(el.value);
|
const target = $(el);
|
||||||
|
codeList[idx].codeSq = Number(target.attr("data-codesq"));
|
||||||
|
codeList[idx].category = target.attr("data-category");
|
||||||
|
codeList[idx].value = target.attr("data-value");
|
||||||
|
codeList[idx].description = target.attr("data-description");
|
||||||
codeList[idx].isDeleted = 'Y';
|
codeList[idx].isDeleted = 'Y';
|
||||||
})
|
})
|
||||||
$.ajaxSettings.traditional = true;
|
if(codeList.length !== 0){
|
||||||
$.ajax({
|
if(confirm(codeList.length+"건을 삭제하시겠습니까?")){
|
||||||
type : 'POST',
|
$.ajax({
|
||||||
url : "/admin/deleteCode",
|
type : 'PUT',
|
||||||
data : JSON.stringify(codeList),
|
url : "/admin/deleteCode",
|
||||||
contentType: 'application/json',
|
data : JSON.stringify(codeList),
|
||||||
beforeSend: function (xhr){
|
contentType: 'application/json',
|
||||||
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
beforeSend: function (xhr){
|
||||||
},
|
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
||||||
success : function(data) {
|
},
|
||||||
debugger
|
success : function(data) {
|
||||||
},
|
alert("삭제되었습니다.");
|
||||||
error : function(xhr, status) {
|
getValues($(".categoryCheckBox:checked").val());
|
||||||
|
},
|
||||||
|
error : function(xhr, status) {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getValues(category){
|
function getValues(category){
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<tr class="valueTr" th:each="commonCode:${valueList}">
|
<tr class="valueTr" th:each="commonCode:${valueList}">
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" class="valueCheckBox"
|
<input type="checkbox" class="valueCheckBox"
|
||||||
th:data-codeSq="${commonCode.codeSq}"
|
th:data-codesq="${commonCode.codeSq}"
|
||||||
th:data-category="${commonCode.category}"
|
th:data-category="${commonCode.category}"
|
||||||
th:data-value="${commonCode.value}"
|
th:data-value="${commonCode.value}"
|
||||||
th:data-description="${commonCode.description}">
|
th:data-description="${commonCode.description}">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue