83 lines
3.6 KiB
Plaintext
83 lines
3.6 KiB
Plaintext
<#import "admin/admin-shell.ftl" as shell>
|
|
<@shell.page title="后台管理 - 用户与角色" active=active adminName=adminName>
|
|
<h2 class="ui header">用户与角色管理</h2>
|
|
<p class="small-muted">简单 RBAC:用户可绑定多个角色,拥有 ADMIN 角色的用户可以进入后台管理。</p>
|
|
|
|
<h3 class="ui dividing header">角色管理</h3>
|
|
<form class="ui form" method="post" action="/admin/roles">
|
|
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
|
<div class="three fields">
|
|
<div class="field"><label>角色编码</label><input name="code" placeholder="如 ADMIN_AUDIT" required></div>
|
|
<div class="field"><label>角色名称</label><input name="name" placeholder="如 审计管理员" required></div>
|
|
<div class="field"><label>描述</label><input name="description" placeholder="角色用途说明"></div>
|
|
</div>
|
|
<button class="ui small primary button" type="submit">新增角色</button>
|
|
</form>
|
|
|
|
<table class="ui celled compact table">
|
|
<thead><tr><th>ID</th><th>编码</th><th>名称</th><th>状态</th><th>操作</th></tr></thead>
|
|
<tbody>
|
|
<#list roles as r>
|
|
<tr>
|
|
<td>${r.id}</td>
|
|
<td>${r.code!""}</td>
|
|
<td>${r.name!""}</td>
|
|
<td><#if r.enabled?? && r.enabled==1>启用<#else>停用</#if></td>
|
|
<td>
|
|
<form style="display:inline" method="post" action="/admin/roles/${r.id}/toggle">
|
|
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
|
<button class="ui tiny button" type="submit">切换启停</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
</#list>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h3 class="ui dividing header">用户角色绑定</h3>
|
|
<table class="ui celled table">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>用户名</th>
|
|
<th>邮箱</th>
|
|
<th>角色绑定</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<#list users as u>
|
|
<tr>
|
|
<td>${u.id}</td>
|
|
<td>${u.username!""}</td>
|
|
<td>${u.email!""}</td>
|
|
<td>
|
|
<form class="ui form" method="post" action="/admin/users/${u.id}/roles">
|
|
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
|
<div class="inline fields">
|
|
<#list roles as r>
|
|
<div class="field">
|
|
<div class="ui checkbox">
|
|
<input type="checkbox" name="roleIds" value="${r.id}"
|
|
<#if userRoleIds[u.id?c]?? && userRoleIds[u.id?c]?seq_contains(r.id)>checked</#if>>
|
|
<label>${r.code}</label>
|
|
</div>
|
|
</div>
|
|
</#list>
|
|
</div>
|
|
<button class="ui tiny primary button" type="submit">保存角色</button>
|
|
</form>
|
|
</td>
|
|
<td>
|
|
<a class="ui tiny button" href="/user?id=${u.id}" target="_blank">查看用户页</a>
|
|
</td>
|
|
</tr>
|
|
</#list>
|
|
</tbody>
|
|
</table>
|
|
|
|
<script>
|
|
$('.ui.checkbox').checkbox();
|
|
</script>
|
|
</@shell.page>
|