# Conflicts:
#	src/main/java/com/dbnt/faisp/config/SecurityConfig.java
TaehunPark 2022-08-30 12:04:18 +09:00
commit 79a76da678
20 changed files with 394 additions and 112 deletions

View File

@ -3,6 +3,7 @@ package com.dbnt.faisp.authMgt;
import com.dbnt.faisp.authMgt.mapper.AuthMgtMapper;
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.authMgt.repository.AccessConfigRepository;
import com.dbnt.faisp.authMgt.repository.ApprovalConfigRepository;
import com.dbnt.faisp.userInfo.model.UserInfo;
@ -27,4 +28,9 @@ public class AuthMgtService {
public List<ApprovalConfig> selectApprovalConfigList(UserInfo 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

@ -41,10 +41,11 @@ public class CodeMgtService{
}
public List<CodeMgt> selectCommonCodeList() {
return codeMgtRepository.findByUseChkOrderByItemCdAsc("T");
//return codeMgtRepository.findByUseChkOrderByItemCdAsc("T");
return codeMgtRepository.findByOrderByItemCdAsc();
}
public List<CodeMgt> selectCodeMgtList(String categoryCd) {
return codeMgtRepository.findByCategoryCdOrderByItemCdAsc(categoryCd);
return codeMgtRepository.findByCategoryCdAndUseChkOrderByItemCdAsc(categoryCd, "T");
}
}

View File

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

View File

@ -6,8 +6,9 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum Role {
ADMIN("ROLE_ADMIN"),
USER("ROLE_USER");
ADMIN("ROLE_ADMIN"),
SUB_ADMIN("ROLE_SUB_ADMIN"),
USER("ROLE_USER");
private String value;
private String value;
}

View File

@ -1,6 +1,9 @@
package com.dbnt.faisp.controller;
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.userInfo.UserInfoService;
import com.dbnt.faisp.userInfo.model.UserInfo;
@ -8,18 +11,19 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping("/authMgt")
public class AuthMgtController {
private final MenuMgtService menuMgtService;
private final UserInfoService userInfoService;
private final AuthMgtService authMgtService;
@GetMapping("/authMgtPage")
public ModelAndView menuMgtPage(UserInfo userInfo) {
public ModelAndView authMgtPage(UserInfo userInfo) {
ModelAndView mav = new ModelAndView("adminPage/authMgt/authMgt");
userInfo.setQueryInfo();
mav.addObject("userInfoList", userInfoService.selectUserInfoList(userInfo));
@ -38,23 +42,10 @@ public class AuthMgtController {
return mav;
}
/*@GetMapping("/menuEditModal")
public ModelAndView menuEditModal(MenuMgt menuMgt){
ModelAndView mav = new ModelAndView("/adminPage/menuMgt/menuEditModal");
mav.addObject("menuMgt", menuMgt);
return mav;
}
@PostMapping("/saveMenuMgt")
public String saveMenuMgt(MenuMgt menuMgt){
return menuMgtService.saveMenuMgt(menuMgt);
}
@PostMapping("/deleteMenuMgt")
@ResponseBody
public String deleteMenuMgt(@RequestBody List<MenuMgt> menuMgt){
menuMgtService.deleteMenuMgt(menuMgt);
@PostMapping("/saveAuth")
public String saveAuth(@RequestBody AuthMgt authMgt){
authMgtService.saveAuth(authMgt);
return "";
}*/
}
}

View File

@ -0,0 +1,23 @@
package com.dbnt.faisp.controller;
import com.dbnt.faisp.organMgt.OrganConfigService;
import com.dbnt.faisp.userInfo.model.UserInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@RestController
@RequiredArgsConstructor
@RequestMapping("/organMgt")
public class OrganConfigController {
private final OrganConfigService organConfigService;
@GetMapping("/organMgtPage")
public ModelAndView organMgtPage(UserInfo userInfo) {
ModelAndView mav = new ModelAndView("adminPage/organMgt/organMgt");
mav.addObject("searchParams", userInfo);
return mav;
}
}

View File

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

View File

@ -0,0 +1,10 @@
package com.dbnt.faisp.organMgt;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class OrganConfigService {
}

View File

@ -0,0 +1,30 @@
package com.dbnt.faisp.organMgt.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.*;
import java.util.List;
@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@Table(name = "organ_config")
public class OrganConfig {
@Id
@Column(name = "organ_cd")
private String organCd;
@Column(name = "organ_type")
private String organType;
@Column(name = "parent_organ")
private String parentOrgan;
@Transient
private List<OrganConfig> organConfigList;
}

View File

@ -0,0 +1,9 @@
package com.dbnt.faisp.organMgt.repository;
import com.dbnt.faisp.organMgt.model.OrganConfig;
import org.springframework.data.jpa.repository.JpaRepository;
public interface OrganConfigRepository extends JpaRepository<OrganConfig, String> {
}

View File

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

View File

@ -13,4 +13,55 @@ $(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(),
cat2Cd: row.find(".cat2Cd").val(),
cat3Cd: row.find(".cat3Cd").val(),
menuUrl: row.find(".menuUrl").val()
menuUrl: row.find(".menuUrl").val(),
approvalChk: row.find(".approvalChk").val()
})
}
}

View File

@ -0,0 +1,21 @@
const organConfigList = []
$(document).on('click', '#middleAddBtn', function (){
addTr('middleTbody')
})
$(document).on('click', '#bottomAddBtn', function (){
addTr('bottomTbody')
})
$(document).on('click', '.rowDeleteBtn', function (){
$(this).parents('tr').remove();
})
function addTr(tbody){
$('#'+tbody).append(
'<tr '+(tbody==="middleTbody"?'class="middleTr"':'')+'>' +
'<td><button class="btn btn-sm btn-outline-danger rowDeleteBtn"><i class="bi bi-x"></i></button></td>' +
'<td></td>' +
'</tr>'
)
}

View File

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

View File

@ -55,6 +55,12 @@
<input type="text" class="form-control form-control-sm" id="menuUrl" name="menuUrl" th:value="${menuMgt.menuUrl}">
</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>
</div>
<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="cat3Cd" th:value="${menuMgt.cat3Cd}">
<input type="hidden" class="menuUrl" th:value="${menuMgt.menuUrl}">
<input type="hidden" class="approvalChk" th:value="${menuMgt.approvalChk}">
<td>
<input type="checkbox" class="menuCheckBox" th:value="${menuMgt.menuKey}">
</td>

View File

@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
<script type="text/javascript" th:src="@{/js/organMgt/organMgt.js}"></script>
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<h4>관서 설정</h4>
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="row mx-0">
<div class="col-12 card text-center">
<div class="card-body">
<div class="row">
<div class="col-6">
<div class="row justify-content-end">
<button class="col-auto btn btn-success mx-3 my-2" id="codeSaveBtn">저장</button>
</div>
</div>
</div>
<div class="row justify-content-start">
<div class="col-3" id="middleOrganDiv">
<div class="card">
<div class="card-body">
<div class="row">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>지방청</th>
</tr>
</thead>
<tbody id="middleTbody">
</tbody>
</table>
</div>
<div class="row justify-content-center">
<button class="btn btn-sm btn-outline-primary col-auto" id="middleAddBtn"><i class="bi bi-plus-lg"></i></button>
</div>
</div>
</div>
</div>
<div class="col-3" id="bottomOrganDiv">
<div class="card">
<div class="card-body">
<div class="row">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th>관할서</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr id="emptyTr"><td colspan="2">지방청을 선택해주세요.</td></tr>
</tfoot>
</table>
</div>
<div class="row justify-content-center" id="bottomBtnRow" style="display: none">
<button class="btn btn-sm btn-outline-primary col-auto" id="bottomAddBtn"><i class="bi bi-plus-lg"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<div class="modal fade" id="authEditModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="authEditModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content" id="authEditModalContent">
<div class="modal-header">
<h5 class="modal-title" id="menuEditModalLabel">권한 편집</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
<button type="button" class="btn btn-primary" id="saveAuthBtn">저장</button>
</div>
</div>
</div>
</div>
</div>
</html>

View File

@ -12,12 +12,19 @@
<div>
<ul class="nav nav-pills" sec:authorize="hasRole('ROLE_ADMIN')">
<li class="nav-item"><a href="/codeMgt/codeMgtPage" class="nav-link p-1 link-dark">코드관리</a></li>
<li class="nav-item"><a href="/organMgt/organMgtPage" class="nav-link p-1 link-dark">관서설정</a></li>
<li class="nav-item"><a href="/menuMgt/menuMgtPage" class="nav-link p-1 link-dark">메뉴관리</a></li>
<li class="nav-item"><a href="/userMgt/userMgtPage" class="nav-link p-1 link-dark">외사경찰관리</a></li>
<li class="nav-item"><a href="/authMgt/authMgtPage" class="nav-link p-1 link-dark">권한설정</a></li>
<li class="nav-item"><a href="#" class="nav-link p-1 link-dark">사용자로그</a></li>
<li class="nav-item"><a href="#" class="nav-link p-1 link-dark">접속설정</a></li>
</ul>
<ul class="nav nav-pills" sec:authorize="hasRole('ROLE_SUB_ADMIN')">
<li class="nav-item"><a href="#" class="nav-link p-1 link-dark">외사경찰관리</a></li>
<li class="nav-item"><a href="/authMgt/authMgtPage" class="nav-link p-1 link-dark">권한설정</a></li>
<li class="nav-item"><a href="#" class="nav-link p-1 link-dark">사용자로그</a></li>
<li class="nav-item"><a href="#" class="nav-link p-1 link-dark">접속설정</a></li>
</ul>
</div>
<div sec:authorize="isAuthenticated()">
<ul class="nav nav-pills">