권한설정 기능 작업완료.

메뉴관리 결제기능여부 체크 추가.
강석 최 2022-08-29 16:00:08 +09:00
parent 9e362320eb
commit 29a088eaba
10 changed files with 192 additions and 88 deletions

View File

@ -3,6 +3,7 @@ package com.dbnt.faisp.authMgt;
import com.dbnt.faisp.authMgt.mapper.AuthMgtMapper; import com.dbnt.faisp.authMgt.mapper.AuthMgtMapper;
import com.dbnt.faisp.authMgt.model.AccessConfig; import com.dbnt.faisp.authMgt.model.AccessConfig;
import com.dbnt.faisp.authMgt.model.ApprovalConfig; import com.dbnt.faisp.authMgt.model.ApprovalConfig;
import com.dbnt.faisp.authMgt.model.AuthMgt;
import com.dbnt.faisp.authMgt.repository.AccessConfigRepository; import com.dbnt.faisp.authMgt.repository.AccessConfigRepository;
import com.dbnt.faisp.authMgt.repository.ApprovalConfigRepository; import com.dbnt.faisp.authMgt.repository.ApprovalConfigRepository;
import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.userInfo.model.UserInfo;
@ -27,4 +28,9 @@ public class AuthMgtService {
public List<ApprovalConfig> selectApprovalConfigList(UserInfo userInfo) { public List<ApprovalConfig> selectApprovalConfigList(UserInfo userInfo) {
return authMgtMapper.selectApprovalConfigList(userInfo); return authMgtMapper.selectApprovalConfigList(userInfo);
} }
public void saveAuth(AuthMgt authMgt) {
accessConfigRepository.saveAll(authMgt.getAccessConfigList());
approvalConfigRepository.saveAll(authMgt.getApprovalConfigList());
}
} }

View File

@ -0,0 +1,13 @@
package com.dbnt.faisp.authMgt.model;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class AuthMgt {
List<AccessConfig> accessConfigList;
List<ApprovalConfig> approvalConfigList;
}

View File

@ -1,6 +1,9 @@
package com.dbnt.faisp.controller; package com.dbnt.faisp.controller;
import com.dbnt.faisp.authMgt.AuthMgtService; import com.dbnt.faisp.authMgt.AuthMgtService;
import com.dbnt.faisp.authMgt.model.AccessConfig;
import com.dbnt.faisp.authMgt.model.ApprovalConfig;
import com.dbnt.faisp.authMgt.model.AuthMgt;
import com.dbnt.faisp.menuMgt.MenuMgtService; import com.dbnt.faisp.menuMgt.MenuMgtService;
import com.dbnt.faisp.userInfo.UserInfoService; import com.dbnt.faisp.userInfo.UserInfoService;
import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.userInfo.model.UserInfo;
@ -8,6 +11,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@ -38,6 +43,13 @@ public class AuthMgtController {
return mav; return mav;
} }
@PostMapping("/saveAuth")
@ResponseBody
public String saveAuth(@RequestBody AuthMgt authMgt){
authMgtService.saveAuth(authMgt);
return "";
}
/*@GetMapping("/menuEditModal") /*@GetMapping("/menuEditModal")
public ModelAndView menuEditModal(MenuMgt menuMgt){ public ModelAndView menuEditModal(MenuMgt menuMgt){
ModelAndView mav = new ModelAndView("/adminPage/menuMgt/menuEditModal"); ModelAndView mav = new ModelAndView("/adminPage/menuMgt/menuEditModal");

View File

@ -29,6 +29,8 @@ public class MenuMgt extends BaseModel {
private String cat3Cd; private String cat3Cd;
@Column(name = "menu_url", nullable = false) @Column(name = "menu_url", nullable = false)
private String menuUrl; private String menuUrl;
@Column(name = "approval_chk")
private String approvalChk;
@Transient @Transient
private Integer cat1RowspanCnt; private Integer cat1RowspanCnt;

View File

@ -9,7 +9,8 @@
cat1_cd as cat1Cd, cat1_cd as cat1Cd,
cat2_cd as cat2Cd, cat2_cd as cat2Cd,
cat3_cd as cat3Cd, cat3_cd as cat3Cd,
menu_url as menuUrl menu_url as menuUrl,
approval_chk as approvalChk
from menu_mgt from menu_mgt
<where> <where>
<if test='cat1Cd != null and cat1Cd != ""'> <if test='cat1Cd != null and cat1Cd != ""'>

View File

@ -14,3 +14,54 @@ $(document).on('click', '.userInfoTr', function (){
} }
}); });
}) })
$(document).on('click', '.radioTd', function (){
$(this).find('input').prop('checked', true);
})
$(document).on('click', '#saveAuthBtn', function (){
if(confirm("저장하시겠습니까?")){
contentFade("in");
const userSeq = Number($("#userSeq").val());
const accessConfigList = []
$("#accessEditTable").find('tbody').children().each(function (idx, tr){
accessConfigList.push(
{
userSeq: userSeq,
menuKey: Number($(this).find('.menuKey').val()),
accessAuth: $(this).find('input:checked').val()
}
)
})
const approvalConfigList = []
$("#approvalEditTable").find('input:checked').each(function (idx, tr){
approvalConfigList.push(
{
userSeq: userSeq,
menuKey: Number($(this).parents('tbody').find('.menuKey').val()),
approvalAuth: $(this).val()
}
)
})
const authList = {};
authList.accessConfigList = accessConfigList;
authList.approvalConfigList = approvalConfigList;
$.ajax({
type : 'POST',
url : "/authMgt/saveAuth",
data : JSON.stringify(authList),
contentType: 'application/json',
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function(data) {
alert("저장되었습니다.");
contentFade("out");
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
})

View File

@ -13,7 +13,8 @@ $(document).on('click', '.menuTr', function (event){
cat1Cd: row.find(".cat1Cd").val(), cat1Cd: row.find(".cat1Cd").val(),
cat2Cd: row.find(".cat2Cd").val(), cat2Cd: row.find(".cat2Cd").val(),
cat3Cd: row.find(".cat3Cd").val(), cat3Cd: row.find(".cat3Cd").val(),
menuUrl: row.find(".menuUrl").val() menuUrl: row.find(".menuUrl").val(),
approvalChk: row.find(".approvalChk").val()
}) })
} }
} }

View File

@ -1,89 +1,100 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"> <html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="tab-pane fade show active" id="accessTabPanel" role="tabpanel" aria-labelledby="accessTab" tabindex="0"> <input type="hidden" id="userSeq" th:value="${userInfo.userSeq}">
<form id="accessEditForm" action="#" method="post"> <div class="tab-pane fade show active" id="accessTabPanel" role="tabpanel" aria-labelledby="accessTab" tabindex="0">
<table class="table table-hover text-center"> <table class="table table-hover text-center" id="accessEditTable">
<thead> <thead>
<tr> <tr>
<th>대분류</th> <th>대분류</th>
<th>중분류</th> <th>중분류</th>
<th>소분류</th> <th>소분류</th>
<th>관리</th> <th>관리</th>
<th>작성</th> <th>작성</th>
<th>조회</th> <th>조회</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="accessConfig:${userInfo.accessConfigList}"> <tr th:each="accessConfig:${userInfo.accessConfigList}">
<th:block th:each="commonCode:${session.commonCodeList}"> <input type="hidden" class="menuKey" th:value="${accessConfig.menuKey}">
<th:block th:if="${commonCode.itemCd eq accessConfig.cat1Cd}"> <th:block th:each="commonCode:${session.commonCodeList}">
<td th:text="${commonCode.itemValue}"></td> <th:block th:if="${commonCode.itemCd eq accessConfig.cat1Cd}">
</th:block> <td th:text="${commonCode.itemValue}"></td>
</th:block> </th:block>
<th:block th:each="commonCode:${session.commonCodeList}"> </th:block>
<th:block th:if="${commonCode.itemCd eq accessConfig.cat2Cd}"> <th:block th:each="commonCode:${session.commonCodeList}">
<td th:text="${commonCode.itemValue}"></td> <th:block th:if="${commonCode.itemCd eq accessConfig.cat2Cd}">
</th:block> <td th:text="${commonCode.itemValue}"></td>
</th:block> </th:block>
<th:block th:if="${#strings.isEmpty(accessConfig.cat3Cd)}"> </th:block>
<td></td> <th:block th:if="${#strings.isEmpty(accessConfig.cat3Cd)}">
</th:block> <td></td>
<th:block th:unless="${#strings.isEmpty(accessConfig.cat3Cd)}" th:each="commonCode:${session.commonCodeList}"> </th:block>
<th:block th:if="${commonCode.itemCd eq accessConfig.cat3Cd}"> <th:block th:unless="${#strings.isEmpty(accessConfig.cat3Cd)}" th:each="commonCode:${session.commonCodeList}">
<td th:text="${commonCode.itemValue}"></td> <th:block th:if="${commonCode.itemCd eq accessConfig.cat3Cd}">
</th:block> <td th:text="${commonCode.itemValue}"></td>
</th:block> </th:block>
<td> </th:block>
<input type="radio" th:name="${#strings.concat('accessAuth',accessConfig.menuKey)}" th:checked="${'ACC003' eq accessConfig.accessAuth}" value="ACC003"> <td class="radioTd">
</td> <input type="radio" th:name="${#strings.concat('accessAuth',accessConfig.menuKey)}" th:checked="${'ACC003' eq accessConfig.accessAuth}" value="ACC003">
<td> </td>
<input type="radio" th:name="${#strings.concat('accessAuth',accessConfig.menuKey)}" th:checked="${'ACC002' eq accessConfig.accessAuth}" value="ACC002"> <td class="radioTd">
</td> <input type="radio" th:name="${#strings.concat('accessAuth',accessConfig.menuKey)}" th:checked="${'ACC002' eq accessConfig.accessAuth}" value="ACC002">
<td> </td>
<input type="radio" th:name="${#strings.concat('accessAuth',accessConfig.menuKey)}" th:checked="${'ACC001' eq accessConfig.accessAuth}" value="ACC001"> <td class="radioTd">
</td> <input type="radio" th:name="${#strings.concat('accessAuth',accessConfig.menuKey)}" th:checked="${'ACC001' eq accessConfig.accessAuth}" value="ACC001">
</tr> </td>
</tbody> </tr>
</table> </tbody>
</form> </table>
</div> </div>
<div class="tab-pane fade" id="approvalTabPanel" role="tabpanel" aria-labelledby="approvalTab" tabindex="0"> <div class="tab-pane fade" id="approvalTabPanel" role="tabpanel" aria-labelledby="approvalTab" tabindex="0">
<form id="approvalEditForm" action="#" method="post"> <table class="table table-hover text-center" id="approvalEditTable">
<table class="table table-hover text-center"> <thead>
<thead> <tr>
<tr> <th>대분류</th>
<th>대분류</th> <th>중분류</th>
<th>중분류</th> <th>소분류</th>
<th>계장대행</th> <th>계장대행</th>
<th>계장</th> <th>계장</th>
<th>과장대행</th> <th>과장대행</th>
<th>과장</th> <th>과장</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="approvalConfig:${userInfo.approvalConfigList}"> <tr th:each="approvalConfig:${userInfo.approvalConfigList}">
<th:block th:each="commonCode:${session.commonCodeList}"> <input type="hidden" class="menuKey" th:value="${approvalConfig.menuKey}">
<th:block th:if="${commonCode.itemCd eq approvalConfig.cat1Cd}"> <th:block th:each="commonCode:${session.commonCodeList}">
<td th:text="${commonCode.itemValue}">.</td> <th:block th:if="${commonCode.itemCd eq approvalConfig.cat1Cd}">
</th:block> <td th:text="${commonCode.itemValue}">.</td>
</th:block> </th:block>
<th:block th:each="commonCode:${session.commonCodeList}"> </th:block>
<th:block th:if="${commonCode.itemCd eq approvalConfig.cat2Cd}"> <th:block th:each="commonCode:${session.commonCodeList}">
<td th:text="${commonCode.itemValue}">.</td> <th:block th:if="${commonCode.itemCd eq approvalConfig.cat2Cd}">
</th:block> <td th:text="${commonCode.itemValue}">.</td>
</th:block> </th:block>
<th:block th:each="commonCode:${session.commonCodeList}"> </th:block>
<th:block th:if="${commonCode.itemCd eq approvalConfig.cat3Cd}"> <th:block th:if="${#strings.isEmpty(approvalConfig.cat3Cd)}">
<td th:text="${commonCode.itemValue}">.</td> <td></td>
</th:block> </th:block>
</th:block> <th:block th:unless="${#strings.isEmpty(approvalConfig.cat3Cd)}" th:each="commonCode:${session.commonCodeList}">
<td></td> <th:block th:if="${commonCode.itemCd eq approvalConfig.cat3Cd}">
<td></td> <td th:text="${commonCode.itemValue}"></td>
<td></td> </th:block>
<td></td> </th:block>
</tr> <td class="radioTd">
</tbody> <input type="radio" th:name="${#strings.concat('approvalAuth',approvalConfig.menuKey)}" th:checked="${'APC004' eq approvalConfig.approvalAuth}" value="APC004">
</table> </td>
</form> <td class="radioTd">
</div> <input type="radio" th:name="${#strings.concat('approvalAuth',approvalConfig.menuKey)}" th:checked="${'APC003' eq approvalConfig.approvalAuth}" value="APC003">
</td>
<td class="radioTd">
<input type="radio" th:name="${#strings.concat('approvalAuth',approvalConfig.menuKey)}" th:checked="${'APC002' eq approvalConfig.approvalAuth}" value="APC002">
</td>
<td class="radioTd">
<input type="radio" th:name="${#strings.concat('approvalAuth',approvalConfig.menuKey)}" th:checked="${'APC001' eq approvalConfig.approvalAuth}" value="APC001">
</td>
</tr>
</tbody>
</table>
</div>
</html> </html>

View File

@ -55,6 +55,12 @@
<input type="text" class="form-control form-control-sm" id="menuUrl" name="menuUrl" th:value="${menuMgt.menuUrl}"> <input type="text" class="form-control form-control-sm" id="menuUrl" name="menuUrl" th:value="${menuMgt.menuUrl}">
</div> </div>
</div> </div>
<div class="row mb-3">
<label for="menuUrl" class="col-sm-4 col-form-label col-form-label-sm text-center">결제기능</label>
<div class="col-sm-6">
<input type="checkbox" id="approvalChk" name="approvalChk" value="T" th:checked="${menuMgt.approvalChk eq 'T'}">
</div>
</div>
</form> </form>
</div> </div>
<div class="modal-footer justify-content-between"> <div class="modal-footer justify-content-between">

View File

@ -85,6 +85,7 @@
<input type="hidden" class="cat2Cd" th:value="${menuMgt.cat2Cd}"> <input type="hidden" class="cat2Cd" th:value="${menuMgt.cat2Cd}">
<input type="hidden" class="cat3Cd" th:value="${menuMgt.cat3Cd}"> <input type="hidden" class="cat3Cd" th:value="${menuMgt.cat3Cd}">
<input type="hidden" class="menuUrl" th:value="${menuMgt.menuUrl}"> <input type="hidden" class="menuUrl" th:value="${menuMgt.menuUrl}">
<input type="hidden" class="approvalChk" th:value="${menuMgt.approvalChk}">
<td> <td>
<input type="checkbox" class="menuCheckBox" th:value="${menuMgt.menuKey}"> <input type="checkbox" class="menuCheckBox" th:value="${menuMgt.menuKey}">
</td> </td>