세션의 공통코드 관리방식 변경

강석 최 2022-08-23 09:44:44 +09:00
parent 02e620ffeb
commit 887a89c59f
4 changed files with 11 additions and 5 deletions

View File

@ -22,7 +22,7 @@ public class BaseController {
if(loginUser == null){
mav = new ModelAndView("redirect:/login");
}else{
session.setAttribute("commonCodeList", codeMgtService.selectCodeCatgAndChild());
session.setAttribute("commonCodeList", codeMgtService.selectCommonCodeList());
mav = new ModelAndView("redirect:/dashboard");
}
return mav;
@ -30,7 +30,7 @@ public class BaseController {
@GetMapping("/refreshSession")
public void getSession(HttpSession session){
session.setAttribute("commonCodeList", codeMgtService.selectCodeCatgAndChild());
session.setAttribute("commonCodeList", codeMgtService.selectCommonCodeList());
}
@GetMapping("/login")

View File

@ -10,4 +10,5 @@ import java.util.Optional;
public interface CodeMgtRepository extends JpaRepository<CodeMgt, CodeMgt.CodeMgtId> {
List<CodeMgt> findByCategoryCdOrderByItemCdAsc(String categoryCd);
List<CodeMgt> findByUseChkOrderByItemCdAsc(String useChk);
}

View File

@ -41,4 +41,8 @@ public class CodeMgtService{
}
return codeCatgList;
}
public List<CodeMgt> selectCommonCodeList() {
return codeMgtRepository.findByUseChkOrderByItemCdAsc("T");
}
}

View File

@ -32,12 +32,13 @@ $(document).on('click', '#itemAddBtn', function (){
$('#itemTable').find('tbody').append(
'<tr class="itemTr">' +
'<td><button class="btn btn-sm btn-outline-danger rowDeleteBtn"><i class="bi bi-x"></i></button></td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemCd"></td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemCd" value="'+codeCategoryList[selectedCategoryIdx].categoryCd+'"></td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemValue"></td>'+
'<td></td>'+
'</tr>'
)
codeCategoryList[selectedCategoryIdx].itemList.push({categoryCd:codeCategoryList[selectedCategoryIdx].categoryCd, itemCd:"", itemValue: "", useChk: "", status:"new"})
codeCategoryList[selectedCategoryIdx].itemList
.push({categoryCd:codeCategoryList[selectedCategoryIdx].categoryCd, itemCd:codeCategoryList[selectedCategoryIdx].categoryCd, itemValue: "", useChk: "T", status:"new"})
})
$(document).on('click', '.rowDeleteBtn', function (){
@ -149,7 +150,7 @@ function makeItemTr(itemList){
'<td>'+(item.status==="new"?'<button class="btn btn-sm btn-outline-danger rowDeleteBtn"><i class="bi bi-x"></i></button>':'')+'</td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemCd" value="'+item.itemCd+'"></td>'+
'<td><input type="text" class="form-control form-control-sm itemInput" name="itemValue" value="'+item.itemValue+'"></td>'+
'<td><input type="checkbox" class="itemInput" name="useChk" '+(item.useChk==="T"?'checked':'')+'></td>'+
'<td>'+(item.status==="new"?'':'<input type="checkbox" class="itemInput" name="useChk" '+(item.useChk==="T"?'checked':'')+'>')+'</td>'+
'</tr>'
)
});