fix #477: add group based role grants

This commit is contained in:
devmrko
2026-06-26 09:33:49 +09:00
parent 3c9bcfdc0a
commit 1ea8d34f31
14 changed files with 654 additions and 10 deletions

View File

@@ -0,0 +1,173 @@
<!doctype html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/layout :: head('그룹 관리')}"></head>
<body>
<nav th:replace="~{fragments/layout :: nav}"></nav>
<main class="container py-4">
<div class="page-title">
<h1>그룹 관리</h1>
<p>사용자 그룹을 만들고 그룹에 사용자와 역할을 부여합니다. 권한은 역할에 연결되고, 사용자는 직접 역할과 그룹 역할을 함께 상속합니다.</p>
</div>
<div class="alert alert-success" th:if="${message}" th:text="${message}"></div>
<section class="content-band">
<h2>그룹 추가</h2>
<form method="post" action="/groups" class="form-grid">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<label>
그룹 코드
<input class="form-control" name="groupCode" placeholder="SALES_TEAM" required>
</label>
<label>
그룹명
<input class="form-control" name="groupName" placeholder="영업팀" required>
</label>
<label class="span-2">
설명
<input class="form-control" name="description" maxlength="200">
</label>
<button class="btn rw-btn-primary" type="submit">추가</button>
</form>
</section>
<section class="content-band">
<h2>그룹 목록</h2>
<div class="table-responsive">
<table class="table table-sm align-middle">
<thead>
<tr>
<th>ID</th>
<th>코드</th>
<th>그룹명</th>
<th>설명</th>
<th>상태</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="group : ${groups}">
<td th:text="${group.groupId()}">1</td>
<td><code th:text="${group.groupCode()}">SALES_TEAM</code></td>
<td th:text="${group.groupName()}">영업팀</td>
<td th:text="${group.description()}">설명</td>
<td><span class="badge" th:classappend="${group.active()} ? ' text-bg-success' : ' text-bg-secondary'" th:text="${group.activeYn()}">Y</span></td>
<td>
<form method="post" action="/groups/active" class="inline-form">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<input type="hidden" name="groupId" th:value="${group.groupId()}">
<input type="hidden" name="active" th:value="${!group.active()}">
<button class="btn btn-sm btn-outline-secondary" type="submit" th:text="${group.active()} ? '비활성화' : '활성화'">변경</button>
</form>
</td>
</tr>
<tr th:if="${#lists.isEmpty(groups)}">
<td colspan="6" class="text-muted">등록된 그룹이 없습니다.</td>
</tr>
</tbody>
</table>
</div>
</section>
<section class="content-band">
<h2>그룹 사용자</h2>
<form method="post" action="/groups/users" class="form-grid">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<label>
그룹
<select class="form-select group-master-select" id="groupUserMaster" name="groupId" required>
<option th:each="group : ${groups}" th:value="${group.groupId()}" th:text="${group.groupCode() + ' / ' + group.groupName()}"></option>
</select>
</label>
<label>
추가할 사용자
<select class="form-select" name="userId" required>
<option th:each="user : ${users}" th:value="${user.userId()}" th:text="${user.username()}"></option>
</select>
</label>
<button class="btn rw-btn-primary" type="submit">추가</button>
</form>
<h2 class="mt-4">선택 그룹 사용자</h2>
<div class="table-responsive">
<table class="table table-sm align-middle" data-group-detail-table="groupUserMaster" data-empty-message="선택한 그룹에 사용자가 없습니다.">
<thead>
<tr>
<th>그룹</th>
<th>사용자</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="mapping : ${groupUsers}" th:attr="data-group-id=${mapping.groupId()}">
<td><code th:text="${mapping.groupCode()}">SALES_TEAM</code></td>
<td th:text="${mapping.username()}">agent_sales</td>
<td>
<form method="post" action="/groups/users/delete" class="inline-form">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<input type="hidden" name="groupId" th:value="${mapping.groupId()}">
<input type="hidden" name="userId" th:value="${mapping.userId()}">
<button class="btn btn-sm btn-outline-danger" type="submit">해제</button>
</form>
</td>
</tr>
<tr th:if="${#lists.isEmpty(groupUsers)}">
<td colspan="3" class="text-muted">등록된 그룹 사용자가 없습니다.</td>
</tr>
</tbody>
</table>
</div>
</section>
<section class="content-band">
<h2>그룹 역할</h2>
<form method="post" action="/groups/roles" class="form-grid">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<label>
그룹
<select class="form-select group-master-select" id="groupRoleMaster" name="groupId" required>
<option th:each="group : ${groups}" th:value="${group.groupId()}" th:text="${group.groupCode() + ' / ' + group.groupName()}"></option>
</select>
</label>
<label>
부여할 역할
<select class="form-select" name="roleId" required>
<option th:each="role : ${roles}" th:value="${role.roleId()}" th:text="${role.roleName()}"></option>
</select>
</label>
<button class="btn rw-btn-primary" type="submit">부여</button>
</form>
<h2 class="mt-4">선택 그룹 역할</h2>
<div class="table-responsive">
<table class="table table-sm align-middle" data-group-detail-table="groupRoleMaster" data-empty-message="선택한 그룹에 부여된 역할이 없습니다.">
<thead>
<tr>
<th>그룹</th>
<th>역할</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="mapping : ${groupRoles}" th:attr="data-group-id=${mapping.groupId()}">
<td><code th:text="${mapping.groupCode()}">SALES_TEAM</code></td>
<td th:text="${mapping.roleName()}">SALES_ROLE</td>
<td>
<form method="post" action="/groups/roles/delete" class="inline-form">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<input type="hidden" name="groupId" th:value="${mapping.groupId()}">
<input type="hidden" name="roleId" th:value="${mapping.roleId()}">
<button class="btn btn-sm btn-outline-danger" type="submit">해제</button>
</form>
</td>
</tr>
<tr th:if="${#lists.isEmpty(groupRoles)}">
<td colspan="3" class="text-muted">등록된 그룹 역할이 없습니다.</td>
</tr>
</tbody>
</table>
</div>
</section>
</main>
</body>
</html>