Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YX_IDENT_REFACTORING
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangyusheng
YX_IDENT_REFACTORING
Commits
6c73aeb9
Commit
6c73aeb9
authored
Oct 22, 2018
by
liboyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
角色和权限修改已完成
parent
84046ca5
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
176 additions
and
81 deletions
+176
-81
ShiroApi.java
src/main/java/com/yxproject/start/api/ShiroApi.java
+18
-4
UserInfoApi.java
src/main/java/com/yxproject/start/api/UserInfoApi.java
+34
-2
SysPermissionMapper.java
.../java/com/yxproject/start/mapper/SysPermissionMapper.java
+25
-1
SysRoleMapper.java
src/main/java/com/yxproject/start/mapper/SysRoleMapper.java
+13
-0
SysPermissionService.java
...ava/com/yxproject/start/service/SysPermissionService.java
+21
-0
SysRoleService.java
...main/java/com/yxproject/start/service/SysRoleService.java
+3
-1
SysPermissionServiceImpl.java
...xproject/start/service/impl/SysPermissionServiceImpl.java
+19
-0
SysRoleServiceImpl.java
.../com/yxproject/start/service/impl/SysRoleServiceImpl.java
+13
-6
permissionAdd.html
src/main/resources/templates/permissionAdd.html
+1
-1
permissionInfo.html
src/main/resources/templates/permissionInfo.html
+1
-22
roleInfo.html
src/main/resources/templates/roleInfo.html
+0
-22
updatePermission.html
src/main/resources/templates/updatePermission.html
+28
-0
userInfo.html
src/main/resources/templates/userInfo.html
+0
-22
No files found.
src/main/java/com/yxproject/start/api/ShiroApi.java
View file @
6c73aeb9
...
...
@@ -100,9 +100,8 @@ public class ShiroApi {
@RequestMapping
(
"/permissionAdd"
)
@RequiresPermissions
(
"permission.add"
)
//权限管理;
public
String
permissionAdd
(
Map
<
String
,
Object
>
map
){
Subject
subject
=
SecurityUtils
.
getSubject
();
UserInfo
ui
=
(
UserInfo
)
subject
.
getPrincipal
();
map
.
put
(
"roleInfo"
,
ui
.
getRoleList
().
get
(
0
));
List
<
SysPermission
>
permissionList
=
sysPermissionService
.
getAllActivePermission
();
map
.
put
(
"permissionList"
,
permissionList
);
return
"permissionAdd"
;
}
...
...
@@ -167,7 +166,7 @@ public class ShiroApi {
}
/**
* 修改
用户.
* 修改
角色
* @return
*/
@RequestMapping
(
"/updateRoleInfo"
)
...
...
@@ -179,5 +178,20 @@ public class ShiroApi {
return
"updateRoleInfo"
;
}
/**
* 修改权限
* @return
*/
@RequestMapping
(
"/updatePermission"
)
public
String
updatePermission
(
@RequestParam
(
"permissionId"
)
String
permissionId
,
Map
<
String
,
Object
>
map
){
SysPermission
sysPermission
=
sysPermissionService
.
getPermissionByPId
(
Integer
.
parseInt
(
permissionId
));
String
parentName
=
sysPermissionService
.
getParentNameByParentId
(
sysPermission
.
getParent_id
());
List
<
SysPermission
>
permissionList
=
sysPermissionService
.
getAllActivePermission
();
map
.
put
(
"sysPermission"
,
sysPermission
);
map
.
put
(
"parentName"
,
parentName
);
map
.
put
(
"permissionList"
,
permissionList
);
return
"updatePermission"
;
}
}
src/main/java/com/yxproject/start/api/UserInfoApi.java
View file @
6c73aeb9
...
...
@@ -309,9 +309,9 @@ public class UserInfoApi {
sysRole
.
setId
(
Integer
.
parseInt
(
roleId
));
sysRole
.
setRole
(
role
);
sysRole
.
setDescription
(
description
);
String
[]
old
p
ermissionIds
=
request
.
getParameterValues
(
"permissionIds"
);
String
[]
old
P
ermissionIds
=
request
.
getParameterValues
(
"permissionIds"
);
String
[]
permissionIds
=
request
.
getParameterValues
(
"permissions"
);
// flag = sysRoleService.updateRole(sysRole,permissionIds,oldp
ermissionIds);
flag
=
sysRoleService
.
updateRole
(
sysRole
,
permissionIds
,
oldP
ermissionIds
);
if
(
flag
){
map
.
put
(
"resultMsg"
,
"修改成功"
);
...
...
@@ -323,6 +323,38 @@ public class UserInfoApi {
}
@POST
@Path
(
"permissionUpdate"
)
@RequiresPermissions
(
"permission.update"
)
public
String
permissionUpdate
(
@FormParam
(
"id"
)
String
id
,
@FormParam
(
"name"
)
String
name
,
@FormParam
(
"resourceType"
)
String
resourceType
,
@FormParam
(
"url"
)
String
url
,
@FormParam
(
"permission"
)
String
permission
,
@FormParam
(
"parentId"
)
String
parentId
,
@Context
HttpServletResponse
resp
){
resp
.
setCharacterEncoding
(
"UTF-8"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
boolean
flag
=
false
;
String
str
=
"0"
;
SysPermission
sysPermission
=
new
SysPermission
();
sysPermission
.
setId
(
Integer
.
parseInt
(
id
));
sysPermission
.
setName
(
name
);
sysPermission
.
setResource_type
(
resourceType
);
sysPermission
.
setUrl
(
url
);
sysPermission
.
setPermission
(
permission
);
sysPermission
.
setParent_id
(
Long
.
parseLong
(
parentId
));
if
(
parentId
.
equals
(
str
)){
sysPermission
.
setParent_ids
(
parentId
+
"/"
);
}
else
{
sysPermission
.
setParent_ids
(
str
+
"/"
+
parentId
);
}
System
.
out
.
println
(
sysPermission
);
flag
=
sysPermissionService
.
updatePermission
(
sysPermission
);
if
(
flag
){
map
.
put
(
"resultMsg"
,
"修改成功"
);
}
else
{
map
.
put
(
"resultMsg"
,
"修改失败"
);
}
return
map
.
toString
();
}
@GET
@RequestMapping
(
"selectAllUser"
)
...
...
src/main/java/com/yxproject/start/mapper/SysPermissionMapper.java
View file @
6c73aeb9
...
...
@@ -54,5 +54,29 @@ public interface SysPermissionMapper{
* @return
*/
@Select
(
"select sp.id,sp.name from SYS_ROLE_PERMISSION srp ,SYS_PERMISSION sp where srp.PERMISSION_ID=sp.ID and srp.ROLE_ID=#{roleId}"
)
List
<
SysPermission
>
selectPermissionByRoleId
(
@Param
(
"roleId"
)
Integer
roleId
);
public
List
<
SysPermission
>
selectPermissionByRoleId
(
@Param
(
"roleId"
)
Integer
roleId
);
/**
*通过id查询权限信息
* @param permissionId
* @return
*/
@Select
(
"select * from SYS_PERMISSION WHERE ID=#{permissionId}"
)
public
SysPermission
selectPermissionByPid
(
@Param
(
"permissionId"
)
Integer
permissionId
);
/**
* 通过父id查询父名称
* @param parentId
* @return
*/
@Select
(
"select name from SYS_PERMISSION WHERE ID=#{parentId}"
)
public
String
selectParentNameById
(
@Param
(
"parentId"
)
Long
parentId
);
/**
* 修改权限信息
* @param sysPermission
*/
@Update
(
"update SYS_PERMISSION SET NAME=#{name},resource_type=#{resource_type},url=#{url},"
+
"permission=#{permission},parent_id=#{parent_id},parent_ids=#{parent_ids} where id=#{id}"
)
public
void
updatePermission
(
SysPermission
sysPermission
);
}
src/main/java/com/yxproject/start/mapper/SysRoleMapper.java
View file @
6c73aeb9
...
...
@@ -93,5 +93,18 @@ public interface SysRoleMapper {
many
=
@Many
(
select
=
"com.yxproject.start.mapper.SysPermissionMapper.selectPermissionByRoleId"
))})
public
SysRole
selectRoleByRoleId
(
@Param
(
"roleId"
)
Integer
roleId
);
/**
* 修改角色信息
* @param sysRole
*/
@Update
(
"update SYS_ROLE set role=#{role},description=#{description} where id=#{id}"
)
public
void
updateSysRole
(
SysRole
sysRole
);
/**
* 删除角色权限关系表中旧关系
* @param roleId
* @param oldPermissionId
*/
@Delete
(
"delete from SYS_ROLE_PERMISSION WHERE ROLE_ID=#{roleId} AND PERMISSION_ID=#{oldPermissionId}"
)
public
void
delRolePermission
(
@Param
(
"roleId"
)
Integer
roleId
,
@Param
(
"oldPermissionId"
)
Integer
oldPermissionId
);
}
src/main/java/com/yxproject/start/service/SysPermissionService.java
View file @
6c73aeb9
...
...
@@ -40,5 +40,26 @@ public interface SysPermissionService {
* @return
*/
public
boolean
backPermission
(
Integer
permissionId
);
/**
* 通过权限id查询权限
* @param permissionId
* @return
*/
public
SysPermission
getPermissionByPId
(
Integer
permissionId
);
/**
* 通过父id查询父名称
* @param parentId
* @return
*/
public
String
getParentNameByParentId
(
Long
parentId
);
/**
* 修改权限信息
* @param sysPermission
* @return
*/
public
boolean
updatePermission
(
SysPermission
sysPermission
);
}
src/main/java/com/yxproject/start/service/SysRoleService.java
View file @
6c73aeb9
...
...
@@ -20,9 +20,11 @@ public interface SysRoleService {
* 修改角色和权限
* @param sysRole
* @param ids
* @param oldIds
* @return
*/
// public boolean updateRole(SysRole sysRole,String[] ids,String[] oldIds);
public
boolean
updateRole
(
SysRole
sysRole
,
String
[]
ids
,
String
[]
oldIds
);
/**
* 查询所有角色
...
...
src/main/java/com/yxproject/start/service/impl/SysPermissionServiceImpl.java
View file @
6c73aeb9
...
...
@@ -3,6 +3,7 @@ package com.yxproject.start.service.impl;
import
com.yxproject.start.entity.SysPermission
;
import
com.yxproject.start.mapper.SysPermissionMapper
;
import
com.yxproject.start.service.SysPermissionService
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -48,5 +49,23 @@ public class SysPermissionServiceImpl implements SysPermissionService{
return
true
;
}
@Override
public
SysPermission
getPermissionByPId
(
Integer
permissionId
)
{
SysPermission
sysPermission
=
sysPermissionMapper
.
selectPermissionByPid
(
permissionId
);
return
sysPermission
;
}
@Override
public
String
getParentNameByParentId
(
Long
parentId
)
{
String
parentName
=
sysPermissionMapper
.
selectParentNameById
(
parentId
);
return
parentName
;
}
@Override
public
boolean
updatePermission
(
SysPermission
sysPermission
)
{
sysPermissionMapper
.
updatePermission
(
sysPermission
);
return
true
;
}
}
src/main/java/com/yxproject/start/service/impl/SysRoleServiceImpl.java
View file @
6c73aeb9
...
...
@@ -31,12 +31,19 @@ public class SysRoleServiceImpl implements SysRoleService {
return
true
;
}
// @Override
// @Transactional(rollbackFor=Exception.class)
// public boolean updateRole(SysRole sysRole,String[] ids,String[] oldIds){
// sysRoleMapper.updateRole(sysRole);
// return true;
// }
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
updateRole
(
SysRole
sysRole
,
String
[]
ids
,
String
[]
oldIds
)
{
sysRoleMapper
.
updateSysRole
(
sysRole
);
for
(
int
i
=
0
;
i
<
oldIds
.
length
;
i
++){
sysRoleMapper
.
delRolePermission
(
sysRole
.
getId
(),
Integer
.
parseInt
(
oldIds
[
i
]));
}
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++){
sysRoleMapper
.
addRolePermission
(
sysRole
.
getId
(),
Integer
.
parseInt
(
ids
[
i
]));
}
return
true
;
}
@Override
public
List
<
SysRole
>
getAllRoleInfo
()
{
...
...
src/main/resources/templates/permissionAdd.html
View file @
6c73aeb9
...
...
@@ -14,7 +14,7 @@
<p>
权限字符串:
<input
type=
"text"
name=
"permission"
value=
"userInfo.add"
/></p>
<p>
父类:
<select
name=
"parentId"
>
<option
value=
"0"
>
无
</option>
<option
th:each=
"permission:${
roleInfo.permissions
}"
th:value=
"${permission.id}"
>
<option
th:each=
"permission:${
permissionList
}"
th:value=
"${permission.id}"
>
<span
th:text=
"${permission.name}"
></span>
</option>
</select>
...
...
src/main/resources/templates/permissionInfo.html
View file @
6c73aeb9
...
...
@@ -22,16 +22,12 @@
<body
class=
"layui-anim layui-anim-up"
>
<div
class=
"x-body"
>
<xblock>
<button
class=
"layui-btn layui-btn-danger"
onclick=
"delAll()"
><i
class=
"layui-icon"
>
</i>
批量删除
</button>
<button
class=
"layui-btn"
onclick=
"x_admin_show('添加权限','/permissionAdd',600,400)"
><i
class=
"layui-icon"
>
</i>
添加
</button>
<!--<span class="x-right" style="line-height:40px">共有数据:88 条</span>-->
</xblock>
<table
class=
"layui-table"
>
<thead>
<tr>
<th>
<div
class=
"layui-unselect header layui-form-checkbox"
lay-skin=
"primary"
><i
class=
"layui-icon"
>

</i></div>
</th>
<th>
ID
</th>
<th>
权限
</th>
<th>
名称
</th>
...
...
@@ -45,9 +41,6 @@
</thead>
<tbody>
<tr
th:each=
"permission:${permissionList}"
>
<td>
<div
class=
"layui-unselect layui-form-checkbox"
lay-skin=
"primary"
data-id=
'2'
><i
class=
"layui-icon"
>

</i></div>
</td>
<td><span
th:text=
"${permission.id}"
></span></td>
<td><span
th:text=
"${permission.permission}"
></span></td>
<td><span
th:text=
"${permission.name}"
></span></td>
...
...
@@ -60,24 +53,10 @@
<span
th:if=
"${permission.available}==0"
class=
"layui-btn layui-btn-normal layui-btn-mini"
>
已启用
</span>
</td>
<td>
<a
class=
"layui-btn layui-btn"
href=
"#"
th:href=
"@{/
rest/user/updatePermissionInfo
(permissionId=${permission.id})}"
>
修改
</a>
<a
class=
"layui-btn layui-btn"
href=
"#"
th:href=
"@{/
updatePermission
(permissionId=${permission.id})}"
>
修改
</a>
<a
class=
"layui-btn layui-btn-danger"
onclick=
"return del()"
href=
"#"
th:href=
"@{/rest/user/permissionDel(permissionId=${permission.id})}"
>
删除
</a>
<a
class=
"layui-btn layui-btn-info"
href=
"#"
th:href=
"@{/rest/user/permissionBack(permissionId=${permission.id})}"
>
启用
</a>
</td>
<!--<td class="td-manage">-->
<!--<a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a title="编辑" onclick="x_admin_show('编辑','member-edit.html',600,400)" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a onclick="x_admin_show('修改密码','member-password.html',600,400)" title="修改密码" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--</td>-->
</tr>
</tbody>
</table>
...
...
src/main/resources/templates/roleInfo.html
View file @
6c73aeb9
...
...
@@ -22,16 +22,11 @@
<body
class=
"layui-anim layui-anim-up"
>
<div
class=
"x-body"
>
<xblock>
<button
class=
"layui-btn layui-btn-danger"
onclick=
"delAll()"
><i
class=
"layui-icon"
>
</i>
批量删除
</button>
<button
class=
"layui-btn"
onclick=
"x_admin_show('添加角色','/roleAdd',600,400)"
><i
class=
"layui-icon"
>
</i>
添加
</button>
<!--<span class="x-right" style="line-height:40px">共有数据:88 条</span>-->
</xblock>
<table
class=
"layui-table"
>
<thead>
<tr>
<th>
<div
class=
"layui-unselect header layui-form-checkbox"
lay-skin=
"primary"
><i
class=
"layui-icon"
>

</i></div>
</th>
<th>
ID
</th>
<th>
角色名
</th>
<th>
描述
</th>
...
...
@@ -42,9 +37,6 @@
</thead>
<tbody>
<tr
th:each=
"role:${roleInfoList}"
>
<td>
<div
class=
"layui-unselect layui-form-checkbox"
lay-skin=
"primary"
data-id=
'2'
><i
class=
"layui-icon"
>

</i></div>
</td>
<td><span
th:text=
"${role.id}"
></span></td>
<td><span
th:text=
"${role.role}"
></span></td>
<td><span
th:text=
"${role.description}"
></span></td>
...
...
@@ -61,20 +53,6 @@
<a
class=
"layui-btn layui-btn-danger"
onclick=
"return del()"
href=
"#"
th:href=
"@{/rest/user/roleDel(roleId=${role.id})}"
>
删除
</a>
<a
class=
"layui-btn layui-btn-info"
href=
"#"
th:href=
"@{/rest/user/roleBack(roleId=${role.id})}"
>
启用
</a>
</td>
<!--<td class="td-manage">-->
<!--<a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a title="编辑" onclick="x_admin_show('编辑','member-edit.html',600,400)" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a onclick="x_admin_show('修改密码','member-password.html',600,400)" title="修改密码" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--</td>-->
</tr>
</tbody>
</table>
...
...
src/main/resources/templates/updatePermission.html
0 → 100644
View file @
6c73aeb9
<!DOCTYPE html>
<html
lang=
"en"
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Add
</title>
</head>
<body>
<h3>
权限添加界面
</h3>
<form
action=
""
th:action=
"@{rest/user/permissionUpdate}"
method=
"post"
>
<input
type=
"hidden"
name=
"id"
th:value=
"${sysPermission.id}"
/>
<p>
名称:
<input
type=
"text"
name=
"name"
th:value=
"${sysPermission.name}"
/></p>
<p>
资源类型:
<input
type=
"radio"
name=
"resourceType"
value=
"menu"
/>
menu
<input
type=
"radio"
name=
"resourceType"
value=
"button"
/>
button
</p>
<p>
资源路径:
<input
type=
"text"
name=
"url"
th:value=
"${sysPermission.url}"
/></p>
<p>
权限字符串:
<input
type=
"text"
name=
"permission"
th:value=
"${sysPermission.permission}"
/></p>
<p>
父类:
<select
name=
"parentId"
>
<option
value=
"0"
>
无
</option>
<option
th:each=
"permission:${permissionList}"
th:value=
"${permission.id}"
>
<span
th:text=
"${permission.name}"
></span>
</option>
</select>
</p>
</select>
<p><input
type=
"submit"
value=
"添加"
/></p>
</form>
</body>
</html>
\ No newline at end of file
src/main/resources/templates/userInfo.html
View file @
6c73aeb9
...
...
@@ -22,16 +22,11 @@
<body
class=
"layui-anim layui-anim-up"
>
<div
class=
"x-body"
>
<xblock>
<button
class=
"layui-btn layui-btn-danger"
onclick=
"delAll()"
><i
class=
"layui-icon"
>
</i>
批量删除
</button>
<button
class=
"layui-btn"
onclick=
"x_admin_show('添加用户','/userAdd',600,400)"
><i
class=
"layui-icon"
>
</i>
添加
</button>
<!--<span class="x-right" style="line-height:40px">共有数据:88 条</span>-->
</xblock>
<table
class=
"layui-table"
>
<thead>
<tr>
<th>
<div
class=
"layui-unselect header layui-form-checkbox"
lay-skin=
"primary"
><i
class=
"layui-icon"
>

</i></div>
</th>
<th>
ID
</th>
<th>
用户名
</th>
<th>
别名
</th>
...
...
@@ -42,9 +37,6 @@
</thead>
<tbody>
<tr
th:each=
"userInfo:${userInfoList}"
>
<td>
<div
class=
"layui-unselect layui-form-checkbox"
lay-skin=
"primary"
data-id=
'2'
><i
class=
"layui-icon"
>

</i></div>
</td>
<td><span
th:text=
"${userInfo.id}"
></span></td>
<td><span
th:text=
"${userInfo.username}"
></span></td>
<td><span
th:text=
"${userInfo.name}"
></span></td>
...
...
@@ -61,20 +53,6 @@
<a
class=
"layui-btn layui-btn-danger"
onclick=
"return del()"
href=
"#"
th:href=
"@{/rest/user/userDel(userId=${userInfo.id})}"
>
删除
</a>
<a
class=
"layui-btn layui-btn-info"
href=
"#"
th:href=
"@{/rest/user/userBack(userId=${userInfo.id})}"
>
启用
</a>
</td>
<!--<td class="td-manage">-->
<!--<a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a title="编辑" onclick="x_admin_show('编辑','member-edit.html',600,400)" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a onclick="x_admin_show('修改密码','member-password.html',600,400)" title="修改密码" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">-->
<!--<i class="layui-icon"></i>-->
<!--</a>-->
<!--</td>-->
</tr>
</tbody>
</table>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment