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
84046ca5
Commit
84046ca5
authored
Oct 19, 2018
by
liboyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
后台管理页面实现用户角色权限的增删查,角色和权限修改未完成
parent
b1c3a667
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
921 additions
and
86 deletions
+921
-86
ShiroApi.java
src/main/java/com/yxproject/start/api/ShiroApi.java
+58
-8
UserInfoApi.java
src/main/java/com/yxproject/start/api/UserInfoApi.java
+131
-26
SysPermission.java
src/main/java/com/yxproject/start/entity/SysPermission.java
+28
-20
SysRole.java
src/main/java/com/yxproject/start/entity/SysRole.java
+3
-3
UserInfo.java
src/main/java/com/yxproject/start/entity/UserInfo.java
+1
-1
SysPermissionMapper.java
.../java/com/yxproject/start/mapper/SysPermissionMapper.java
+26
-4
SysRoleMapper.java
src/main/java/com/yxproject/start/mapper/SysRoleMapper.java
+49
-3
UserInfoMapper.java
src/main/java/com/yxproject/start/mapper/UserInfoMapper.java
+38
-1
SysPermissionService.java
...ava/com/yxproject/start/service/SysPermissionService.java
+13
-0
SysRoleService.java
...main/java/com/yxproject/start/service/SysRoleService.java
+22
-0
UserInfoService.java
...ain/java/com/yxproject/start/service/UserInfoService.java
+24
-0
SysPermissionServiceImpl.java
...xproject/start/service/impl/SysPermissionServiceImpl.java
+11
-0
SysRoleServiceImpl.java
.../com/yxproject/start/service/impl/SysRoleServiceImpl.java
+19
-11
UserInfoServiceImpl.java
...com/yxproject/start/service/impl/UserInfoServiceImpl.java
+28
-0
index.html
src/main/resources/templates/index.html
+2
-2
login.html
src/main/resources/templates/login.html
+2
-2
permissionInfo.html
src/main/resources/templates/permissionInfo.html
+160
-0
roleInfo.html
src/main/resources/templates/roleInfo.html
+157
-0
updateRoleInfo.html
src/main/resources/templates/updateRoleInfo.html
+25
-0
updateUserInfo.html
src/main/resources/templates/updateUserInfo.html
+104
-0
userInfo.html
src/main/resources/templates/userInfo.html
+18
-3
userInfoAdd.html
src/main/resources/templates/userInfoAdd.html
+2
-2
No files found.
src/main/java/com/yxproject/start/api/ShiroApi.java
View file @
84046ca5
...
@@ -3,7 +3,9 @@ package com.yxproject.start.api;
...
@@ -3,7 +3,9 @@ package com.yxproject.start.api;
import
com.yxproject.start.entity.SysPermission
;
import
com.yxproject.start.entity.SysPermission
;
import
com.yxproject.start.entity.SysRole
;
import
com.yxproject.start.entity.SysRole
;
import
com.yxproject.start.entity.UserInfo
;
import
com.yxproject.start.entity.UserInfo
;
import
com.yxproject.start.service.SysPermissionService
;
import
com.yxproject.start.service.SysRoleService
;
import
com.yxproject.start.service.SysRoleService
;
import
com.yxproject.start.service.UserInfoService
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.apache.shiro.authc.IncorrectCredentialsException
;
import
org.apache.shiro.authc.IncorrectCredentialsException
;
...
@@ -13,6 +15,8 @@ import org.apache.shiro.subject.Subject;
...
@@ -13,6 +15,8 @@ import org.apache.shiro.subject.Subject;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -22,9 +26,15 @@ import java.util.Map;
...
@@ -22,9 +26,15 @@ import java.util.Map;
@Controller
@Controller
public
class
ShiroApi
{
public
class
ShiroApi
{
@Autowired
private
UserInfoService
userInfoService
;
@Autowired
@Autowired
private
SysRoleService
sysRoleService
;
private
SysRoleService
sysRoleService
;
@Autowired
private
SysPermissionService
sysPermissionService
;
@RequestMapping
(
value
={
"/"
,
"/index"
})
@RequestMapping
(
value
={
"/"
,
"/index"
})
public
String
index
(
Map
<
String
,
Object
>
map
){
public
String
index
(
Map
<
String
,
Object
>
map
){
System
.
out
.
println
(
"HomeController.index()"
);
System
.
out
.
println
(
"HomeController.index()"
);
...
@@ -115,19 +125,59 @@ public class ShiroApi {
...
@@ -115,19 +125,59 @@ public class ShiroApi {
@RequestMapping
(
"/userList"
)
@RequestMapping
(
"/userList"
)
@RequiresPermissions
(
"userInfo.view"
)
//权限管理;
@RequiresPermissions
(
"userInfo.view"
)
//权限管理;
public
String
userInfo
(
Map
<
String
,
Object
>
map
){
public
String
userInfo
(
Map
<
String
,
Object
>
map
){
Subject
subject
=
SecurityUtils
.
getSubject
();
List
<
UserInfo
>
list
=
userInfoService
.
getAllUserInfo
();
UserInfo
ui
=
(
UserInfo
)
subject
.
getPrincipal
();
map
.
put
(
"userInfoList"
,
list
);
map
.
put
(
"userInfo"
,
ui
);
return
"userInfo"
;
return
"userInfo"
;
}
}
/**
/**
* 用户删除;
* 角色查询.
* @return
*/
@RequestMapping
(
"/roleList"
)
@RequiresPermissions
(
"userInfo.view"
)
//权限管理;
public
String
roleList
(
Map
<
String
,
Object
>
map
){
List
<
SysRole
>
list
=
sysRoleService
.
getAllRoleInfo
();
map
.
put
(
"roleInfoList"
,
list
);
return
"roleInfo"
;
}
/**
* 权限查询.
* @return
*/
@RequestMapping
(
"/permissionList"
)
@RequiresPermissions
(
"userInfo.view"
)
//权限管理;
public
String
permissionList
(
Map
<
String
,
Object
>
map
){
List
<
SysPermission
>
list
=
sysPermissionService
.
getAllPermission
();
map
.
put
(
"permissionList"
,
list
);
return
"permissionInfo"
;
}
/**
* 修改用户.
* @return
* @return
*/
*/
@RequestMapping
(
"/userDel"
)
@RequestMapping
(
"/updateUserInfo"
)
@RequiresPermissions
(
"userInfo.del"
)
//权限管理;
public
String
updateUserInfo
(
@RequestParam
(
"userId"
)
String
userId
,
Map
<
String
,
Object
>
map
){
public
String
userDel
(){
UserInfo
userInfo
=
userInfoService
.
getUserInfoByUserId
(
Integer
.
parseInt
(
userId
));
return
"userInfoDel"
;
List
<
SysRole
>
roleList
=
sysRoleService
.
getAllRoleInfo
();
map
.
put
(
"userInfo"
,
userInfo
);
map
.
put
(
"roleList"
,
roleList
);
return
"updateUserInfo"
;
}
}
/**
* 修改用户.
* @return
*/
@RequestMapping
(
"/updateRoleInfo"
)
public
String
updateRoleInfo
(
@RequestParam
(
"roleId"
)
String
roleId
,
Map
<
String
,
Object
>
map
){
SysRole
sysRole
=
sysRoleService
.
getRoleByRoleId
(
Integer
.
parseInt
(
roleId
));
List
<
SysPermission
>
permissionList
=
sysPermissionService
.
getAllActivePermission
();
map
.
put
(
"sysRole"
,
sysRole
);
map
.
put
(
"permissionList"
,
permissionList
);
return
"updateRoleInfo"
;
}
}
}
src/main/java/com/yxproject/start/api/UserInfoApi.java
View file @
84046ca5
...
@@ -18,10 +18,7 @@ import org.apache.shiro.subject.Subject;
...
@@ -18,10 +18,7 @@ import org.apache.shiro.subject.Subject;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpRequest
;
import
org.springframework.http.HttpRequest
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -84,14 +81,14 @@ public class UserInfoApi {
...
@@ -84,14 +81,14 @@ public class UserInfoApi {
String
str
=
"0"
;
String
str
=
"0"
;
SysPermission
sysPermission
=
new
SysPermission
();
SysPermission
sysPermission
=
new
SysPermission
();
sysPermission
.
setName
(
name
);
sysPermission
.
setName
(
name
);
sysPermission
.
setResource
T
ype
(
resourceType
);
sysPermission
.
setResource
_t
ype
(
resourceType
);
sysPermission
.
setUrl
(
url
);
sysPermission
.
setUrl
(
url
);
sysPermission
.
setPermission
(
permission
);
sysPermission
.
setPermission
(
permission
);
sysPermission
.
setParent
I
d
(
Long
.
parseLong
(
parentId
));
sysPermission
.
setParent
_i
d
(
Long
.
parseLong
(
parentId
));
if
(
parentId
.
equals
(
str
)){
if
(
parentId
.
equals
(
str
)){
sysPermission
.
setParent
I
ds
(
parentId
+
"/"
);
sysPermission
.
setParent
_i
ds
(
parentId
+
"/"
);
}
else
{
}
else
{
sysPermission
.
setParent
I
ds
(
str
+
"/"
+
parentId
);
sysPermission
.
setParent
_i
ds
(
str
+
"/"
+
parentId
);
}
}
System
.
out
.
println
(
sysPermission
);
System
.
out
.
println
(
sysPermission
);
flag
=
sysPermissionService
.
addPermission
(
sysPermission
);
flag
=
sysPermissionService
.
addPermission
(
sysPermission
);
...
@@ -142,11 +139,39 @@ public class UserInfoApi {
...
@@ -142,11 +139,39 @@ public class UserInfoApi {
@RequiresPermissions
(
"userInfo.del"
)
@RequiresPermissions
(
"userInfo.del"
)
public
String
userInfoDel
(
@QueryParam
(
"userId"
)
String
userId
,
@Context
HttpServletResponse
response
){
public
String
userInfoDel
(
@QueryParam
(
"userId"
)
String
userId
,
@Context
HttpServletResponse
response
){
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
Map
map
=
new
HashMap
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>
();
boolean
flag
=
false
;
boolean
flag
=
false
;
flag
=
userInfoService
.
deleteUserInfo
(
Integer
.
parseInt
(
userId
));
flag
=
userInfoService
.
deleteUserInfo
(
Integer
.
parseInt
(
userId
));
if
(
flag
){
map
.
put
(
"returnMsg"
,
"删除成功"
);
}
else
{
map
.
put
(
"returnMsg"
,
"删除失败"
);
}
return
map
.
toString
();
}
/**
* 用户启用;
* @return
*/
@GET
@Path
(
"userBack"
)
@RequiresPermissions
(
"userInfo.back"
)
public
String
userInfoBack
(
@QueryParam
(
"userId"
)
String
userId
,
@Context
HttpServletResponse
response
){
response
.
setCharacterEncoding
(
"UTF-8"
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
boolean
flag
=
false
;
flag
=
userInfoService
.
BackUserInfo
(
Integer
.
parseInt
(
userId
));
if
(
flag
){
map
.
put
(
"returnMsg"
,
"启用成功"
);
}
else
{
map
.
put
(
"returnMsg"
,
"启用失败"
);
}
return
map
.
toString
();
return
map
.
toString
();
}
}
/**
/**
...
@@ -161,7 +186,32 @@ public class UserInfoApi {
...
@@ -161,7 +186,32 @@ public class UserInfoApi {
Map
map
=
new
HashMap
();
Map
map
=
new
HashMap
();
boolean
flag
=
false
;
boolean
flag
=
false
;
flag
=
sysRoleService
.
deleteRole
(
Integer
.
parseInt
(
roleId
));
flag
=
sysRoleService
.
deleteRole
(
Integer
.
parseInt
(
roleId
));
if
(
flag
){
map
.
put
(
"returnMsg"
,
"删除成功"
);
}
else
{
map
.
put
(
"returnMsg"
,
"删除失败"
);
}
return
map
.
toString
();
}
/**
* 角色启用
* @param roleId
* @param response
* @return
*/
@GET
@Path
(
"roleBack"
)
public
String
roleBack
(
@QueryParam
(
"roleId"
)
String
roleId
,
@Context
HttpServletResponse
response
){
response
.
setCharacterEncoding
(
"UTF-8"
);
Map
map
=
new
HashMap
();
boolean
flag
=
false
;
flag
=
sysRoleService
.
backRole
(
Integer
.
parseInt
(
roleId
));
if
(
flag
){
map
.
put
(
"returnMsg"
,
"启用成功"
);
}
else
{
map
.
put
(
"returnMsg"
,
"启用失败"
);
}
return
map
.
toString
();
return
map
.
toString
();
}
}
...
@@ -171,30 +221,37 @@ public class UserInfoApi {
...
@@ -171,30 +221,37 @@ public class UserInfoApi {
*/
*/
@GET
@GET
@Path
(
"permissionDel"
)
@Path
(
"permissionDel"
)
@RequiresPermissions
(
"permission.del"
)
public
String
permissionDel
(
@QueryParam
(
"permissionId"
)
String
permissionId
,
@Context
HttpServletResponse
response
){
public
String
permissionDel
(
@QueryParam
(
"permissionId"
)
String
permissionId
,
@Context
HttpServletResponse
response
){
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
Map
map
=
new
HashMap
();
Map
map
=
new
HashMap
();
boolean
flag
=
false
;
boolean
flag
=
false
;
flag
=
sysPermissionService
.
deletePermission
(
Integer
.
parseInt
(
permissionId
));
flag
=
sysPermissionService
.
deletePermission
(
Integer
.
parseInt
(
permissionId
));
if
(
flag
){
map
.
put
(
"returnMsg"
,
"删除成功"
);
}
else
{
map
.
put
(
"returnMsg"
,
"删除失败"
);
}
return
map
.
toString
();
}
/**
* 权限启用;
* @return
*/
@GET
@Path
(
"permissionBack"
)
public
String
permissionBack
(
@QueryParam
(
"permissionId"
)
String
permissionId
,
@Context
HttpServletResponse
response
){
response
.
setCharacterEncoding
(
"UTF-8"
);
Map
map
=
new
HashMap
();
boolean
flag
=
false
;
flag
=
sysPermissionService
.
backPermission
(
Integer
.
parseInt
(
permissionId
));
if
(
flag
){
map
.
put
(
"returnMsg"
,
"启用成功"
);
}
else
{
map
.
put
(
"returnMsg"
,
"启用失败"
);
}
return
map
.
toString
();
return
map
.
toString
();
}
}
//
// /**
// * 用户更新;
// * @return
// */
// @RequestMapping(value = "/userUpdate",method = RequestMethod.POST)
// @RequiresPermissions("userInfo.update")//权限管理;
// public String userInfoUpdate(@QueryParam("username") String username, @QueryParam("password") String password){
// System.out.println("username------"+username+" -----password-----"+password);
// UserInfoService systemUserService = new UserInfoServiceImpl();
// int i = systemUserService.updateUsername(new UserInfo());
//// int i = 0;
// System.out.println(i+"------返回值");
// return i+"userInfoAdd";
// }
@POST
@POST
@Path
(
"roleInfoAdd"
)
@Path
(
"roleInfoAdd"
)
...
@@ -219,6 +276,54 @@ public class UserInfoApi {
...
@@ -219,6 +276,54 @@ public class UserInfoApi {
}
}
@POST
@Path
(
"userInfoUpdate"
)
public
String
userInfoUpdate
(
@FormParam
(
"userId"
)
String
userId
,
@FormParam
(
"oldRoleId"
)
String
oldRoleId
,
@FormParam
(
"username"
)
String
username
,
@FormParam
(
"name"
)
String
name
,
@FormParam
(
"roleId"
)
String
roleId
,
@Context
HttpServletResponse
resp
)
{
resp
.
setCharacterEncoding
(
"UTF-8"
);
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setId
(
Integer
.
parseInt
(
userId
));
userInfo
.
setUsername
(
username
);
userInfo
.
setName
(
name
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
boolean
flag
=
false
;
flag
=
userInfoService
.
updateUser
(
userInfo
,
Integer
.
parseInt
(
roleId
),
Integer
.
parseInt
(
oldRoleId
));
if
(
flag
){
map
.
put
(
"resultMsg"
,
"修改成功"
);
}
else
{
map
.
put
(
"resultMsg"
,
"修改失败"
);
}
return
map
.
toString
();
}
@POST
@Path
(
"roleInfoUpdate"
)
public
String
roleInfoUpdate
(
@FormParam
(
"roleId"
)
String
roleId
,
@FormParam
(
"role"
)
String
role
,
@FormParam
(
"description"
)
String
description
,
@Context
HttpServletRequest
request
,
@Context
HttpServletResponse
resp
)
{
resp
.
setCharacterEncoding
(
"UTF-8"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
boolean
flag
=
false
;
SysRole
sysRole
=
new
SysRole
();
sysRole
.
setId
(
Integer
.
parseInt
(
roleId
));
sysRole
.
setRole
(
role
);
sysRole
.
setDescription
(
description
);
String
[]
oldpermissionIds
=
request
.
getParameterValues
(
"permissionIds"
);
String
[]
permissionIds
=
request
.
getParameterValues
(
"permissions"
);
// flag = sysRoleService.updateRole(sysRole,permissionIds,oldpermissionIds);
if
(
flag
){
map
.
put
(
"resultMsg"
,
"修改成功"
);
}
else
{
map
.
put
(
"resultMsg"
,
"修改失败"
);
}
return
map
.
toString
();
}
@GET
@GET
@RequestMapping
(
"selectAllUser"
)
@RequestMapping
(
"selectAllUser"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
...
...
src/main/java/com/yxproject/start/entity/SysPermission.java
View file @
84046ca5
...
@@ -23,7 +23,7 @@ public class SysPermission implements Serializable {
...
@@ -23,7 +23,7 @@ public class SysPermission implements Serializable {
/**
/**
* 资源类型
* 资源类型
*/
*/
private
String
resource
T
ype
;
private
String
resource
_t
ype
;
/**
/**
* 资源路径.
* 资源路径.
*/
*/
...
@@ -32,15 +32,21 @@ public class SysPermission implements Serializable {
...
@@ -32,15 +32,21 @@ public class SysPermission implements Serializable {
* 权限字符串,menu例子:role:*,button例子:role:create,role:update,role:delete,role:view
* 权限字符串,menu例子:role:*,button例子:role:create,role:update,role:delete,role:view
*/
*/
private
String
permission
;
private
String
permission
;
/**
/**
* 父编号
* 父编号
*/
*/
private
Long
parentId
;
private
Long
parent_id
;
/**
/**
* 父编号列表
* 父编号列表
*/
*/
private
String
parent
I
ds
;
private
String
parent
_i
ds
;
private
Boolean
available
=
Boolean
.
FALSE
;
private
byte
available
=
0
;
@ManyToMany
@ManyToMany
@JoinTable
(
name
=
"SysRolePermission"
,
joinColumns
={
@JoinColumn
(
name
=
"permissionId"
)},
inverseJoinColumns
={
@JoinColumn
(
name
=
"roleId"
)})
@JoinTable
(
name
=
"SysRolePermission"
,
joinColumns
={
@JoinColumn
(
name
=
"permissionId"
)},
inverseJoinColumns
={
@JoinColumn
(
name
=
"roleId"
)})
private
List
<
SysRole
>
roles
;
private
List
<
SysRole
>
roles
;
...
@@ -61,12 +67,20 @@ public class SysPermission implements Serializable {
...
@@ -61,12 +67,20 @@ public class SysPermission implements Serializable {
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
String
getResource
T
ype
()
{
public
String
getResource
_t
ype
()
{
return
resource
T
ype
;
return
resource
_t
ype
;
}
}
public
void
setResourceType
(
String
resourceType
)
{
public
void
setResource_type
(
String
resource_type
)
{
this
.
resourceType
=
resourceType
;
this
.
resource_type
=
resource_type
;
}
public
String
getParent_ids
()
{
return
parent_ids
;
}
public
void
setParent_ids
(
String
parent_ids
)
{
this
.
parent_ids
=
parent_ids
;
}
}
public
String
getUrl
()
{
public
String
getUrl
()
{
...
@@ -85,27 +99,21 @@ public class SysPermission implements Serializable {
...
@@ -85,27 +99,21 @@ public class SysPermission implements Serializable {
this
.
permission
=
permission
;
this
.
permission
=
permission
;
}
}
public
Long
getParent
I
d
()
{
public
Long
getParent
_i
d
()
{
return
parent
I
d
;
return
parent
_i
d
;
}
}
public
void
setParent
Id
(
Long
parentI
d
)
{
public
void
setParent
_id
(
Long
parent_i
d
)
{
this
.
parent
Id
=
parentI
d
;
this
.
parent
_id
=
parent_i
d
;
}
}
public
String
getParentIds
()
{
return
parentIds
;
}
public
void
setParentIds
(
String
parentIds
)
{
this
.
parentIds
=
parentIds
;
}
public
Boolean
getAvailable
()
{
public
byte
getAvailable
()
{
return
available
;
return
available
;
}
}
public
void
setAvailable
(
Boolean
available
)
{
public
void
setAvailable
(
byte
available
)
{
this
.
available
=
available
;
this
.
available
=
available
;
}
}
...
...
src/main/java/com/yxproject/start/entity/SysRole.java
View file @
84046ca5
...
@@ -26,7 +26,7 @@ public class SysRole {
...
@@ -26,7 +26,7 @@ public class SysRole {
/**
/**
* 是否可用,如果不可用将不会添加给用户
* 是否可用,如果不可用将不会添加给用户
*/
*/
private
Boolean
available
=
Boolean
.
FALSE
;
private
byte
available
=
0
;
/**
/**
* 角色 -- 权限关系:多对多关系;
* 角色 -- 权限关系:多对多关系;
...
@@ -71,11 +71,11 @@ public class SysRole {
...
@@ -71,11 +71,11 @@ public class SysRole {
this
.
description
=
description
;
this
.
description
=
description
;
}
}
public
Boolean
getAvailable
(
boolean
b
)
{
public
byte
getAvailable
(
)
{
return
available
;
return
available
;
}
}
public
void
setAvailable
(
Boolean
available
)
{
public
void
setAvailable
(
byte
available
)
{
this
.
available
=
available
;
this
.
available
=
available
;
}
}
...
...
src/main/java/com/yxproject/start/entity/UserInfo.java
View file @
84046ca5
...
@@ -27,7 +27,7 @@ public class UserInfo implements Serializable {
...
@@ -27,7 +27,7 @@ public class UserInfo implements Serializable {
return
id
;
return
id
;
}
}
public
void
set
Ui
d
(
Integer
id
)
{
public
void
set
I
d
(
Integer
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
...
...
src/main/java/com/yxproject/start/mapper/SysPermissionMapper.java
View file @
84046ca5
...
@@ -17,20 +17,42 @@ public interface SysPermissionMapper{
...
@@ -17,20 +17,42 @@ public interface SysPermissionMapper{
* @param sysPermission
* @param sysPermission
*/
*/
@Insert
(
"INSERT INTO sys_permission (id,available,name,parent_id,parent_ids,permission,resource_type,url)\n"
+
@Insert
(
"INSERT INTO sys_permission (id,available,name,parent_id,parent_ids,permission,resource_type,url)\n"
+
"VALUES (PERMISSION_seq.nextval,0,#{name},#{parent
Id},#{parentIds},#{permission},#{resourceT
ype},#{url})"
)
"VALUES (PERMISSION_seq.nextval,0,#{name},#{parent
_id},#{parent_ids},#{permission},#{resource_t
ype},#{url})"
)
public
void
addPermissionByMap
(
SysPermission
sysPermission
);
public
void
addPermissionByMap
(
SysPermission
sysPermission
);
/**
/**
* 查询所有用户
* 查询所有可用权限
* @return
*/
@Select
(
"select * from SYS_PERMISSION where available=0"
)
public
List
<
SysPermission
>
selectAllActivePermission
();
/**
* 查询所有权限
* @return
* @return
*/
*/
@Select
(
"select * from SYS_PERMISSION"
)
@Select
(
"select * from SYS_PERMISSION"
)
public
List
<
SysPermission
>
selectAllPermission
();
public
List
<
SysPermission
>
selectAllPermission
();
/**
/**
* 删除
角色
* 删除
权限
* @param permissionId
* @param permissionId
*/
*/
@Update
(
"UPDATE
FROM
SYS_PERMISSION SET AVAILABLE = 1 WHERE ID=#{permissionId}"
)
@Update
(
"UPDATE SYS_PERMISSION SET AVAILABLE = 1 WHERE ID=#{permissionId}"
)
public
void
delPermission
(
@Param
(
"permissionId"
)
Integer
permissionId
);
public
void
delPermission
(
@Param
(
"permissionId"
)
Integer
permissionId
);
/**
* 启用权限
* @param permissionId
*/
@Update
(
"UPDATE SYS_PERMISSION SET AVAILABLE = 0 WHERE ID=#{permissionId}"
)
public
void
backPermission
(
@Param
(
"permissionId"
)
Integer
permissionId
);
/**
* 通过角色id查询权限
* @param roleId
* @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
);
}
}
src/main/java/com/yxproject/start/mapper/SysRoleMapper.java
View file @
84046ca5
...
@@ -29,23 +29,69 @@ public interface SysRoleMapper {
...
@@ -29,23 +29,69 @@ public interface SysRoleMapper {
public
void
addRolePermission
(
@Param
(
"roleId"
)
Integer
roleId
,
@Param
(
"permissionId"
)
Integer
permissionId
);
public
void
addRolePermission
(
@Param
(
"roleId"
)
Integer
roleId
,
@Param
(
"permissionId"
)
Integer
permissionId
);
/**
/**
* 查询所有
用户
* 查询所有
角色
* @return
* @return
*/
*/
@Select
(
"select * from SYS_ROLE"
)
@Select
(
"select * from SYS_ROLE"
)
@Results
({
@Result
(
property
=
"id"
,
column
=
"id"
),
@Result
(
property
=
"role"
,
column
=
"role"
),
@Result
(
property
=
"description"
,
column
=
"description"
),
@Result
(
property
=
"available"
,
column
=
"available"
),
@Result
(
property
=
"permissions"
,
javaType
=
List
.
class
,
column
=
"id"
,
many
=
@Many
(
select
=
"com.yxproject.start.mapper.SysPermissionMapper.selectPermissionByRoleId"
))})
public
List
<
SysRole
>
selectAllRole
();
public
List
<
SysRole
>
selectAllRole
();
/**
/**
* 查询所有
用户
* 查询所有
可用角色
* @return
* @return
*/
*/
@Select
(
"select * from SYS_ROLE WHERE AVAILABLE=0"
)
@Select
(
"select * from SYS_ROLE WHERE AVAILABLE=0"
)
public
List
<
SysRole
>
selectAllActiveRole
();
public
List
<
SysRole
>
selectAllActiveRole
();
/**
* 通过用户id查询角色
* @param userId
* @return
*/
@Select
(
"select sr.id,sr.role from SYS_USER_ROLE sur ,SYS_ROLE sr where sur.ROLE_ID=sr.ID and sur.USER_ID=#{userId}"
)
List
<
SysRole
>
selectRoleByUserId
(
@Param
(
"userId"
)
Integer
userId
);
/**
* 更新用户的角色
* @param userId
* @param roleId
*/
@Update
(
"update SYS_USER_ROLE SET ROLE_ID=#{roleId} where USER_ID=#{userId}"
)
public
void
updateUserRole
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"roleId"
)
Integer
roleId
);
/**
/**
* 删除角色
* 删除角色
* @param roleId
* @param roleId
*/
*/
@Update
(
"UPDATE
FROM
SYS_ROLE SET AVAILABLE = 1 WHERE ID=#{roleId}"
)
@Update
(
"UPDATE SYS_ROLE SET AVAILABLE = 1 WHERE ID=#{roleId}"
)
public
void
delRole
(
@Param
(
"roleId"
)
Integer
roleId
);
public
void
delRole
(
@Param
(
"roleId"
)
Integer
roleId
);
/**
* 启用角色
* @param roleId
*/
@Update
(
"UPDATE SYS_ROLE SET AVAILABLE = 0 WHERE ID=#{roleId}"
)
public
void
backRole
(
@Param
(
"roleId"
)
Integer
roleId
);
/**
* 通过角色id查角色和权限
* @param roleId
* @return
*/
@Select
(
"select * from SYS_ROLE where id=#{roleId}"
)
@Results
({
@Result
(
property
=
"id"
,
column
=
"id"
),
@Result
(
property
=
"role"
,
column
=
"role"
),
@Result
(
property
=
"description"
,
column
=
"description"
),
@Result
(
property
=
"available"
,
column
=
"available"
),
@Result
(
property
=
"permissions"
,
javaType
=
List
.
class
,
column
=
"id"
,
many
=
@Many
(
select
=
"com.yxproject.start.mapper.SysPermissionMapper.selectPermissionByRoleId"
))})
public
SysRole
selectRoleByRoleId
(
@Param
(
"roleId"
)
Integer
roleId
);
}
}
src/main/java/com/yxproject/start/mapper/UserInfoMapper.java
View file @
84046ca5
...
@@ -33,15 +33,52 @@ public interface UserInfoMapper {
...
@@ -33,15 +33,52 @@ public interface UserInfoMapper {
* @return
* @return
*/
*/
@Select
(
"select * from USER_INFO"
)
@Select
(
"select * from USER_INFO"
)
@Results
({
@Result
(
property
=
"id"
,
column
=
"id"
),
@Result
(
property
=
"username"
,
column
=
"username"
),
@Result
(
property
=
"name"
,
column
=
"name"
),
@Result
(
property
=
"password"
,
column
=
"password"
),
@Result
(
property
=
"salt"
,
column
=
"salt"
),
@Result
(
property
=
"state"
,
column
=
"state"
),
@Result
(
property
=
"roleList"
,
javaType
=
List
.
class
,
column
=
"id"
,
many
=
@Many
(
select
=
"com.yxproject.start.mapper.SysRoleMapper.selectRoleByUserId"
))})
public
List
<
UserInfo
>
selectAllUserInfo
();
public
List
<
UserInfo
>
selectAllUserInfo
();
/**
* 通过id查询用户
* @param userId
* @return
*/
@Select
(
"select * from USER_INFO WHERE id=#{userId}"
)
@Results
({
@Result
(
property
=
"id"
,
column
=
"id"
),
@Result
(
property
=
"username"
,
column
=
"username"
),
@Result
(
property
=
"name"
,
column
=
"name"
),
@Result
(
property
=
"password"
,
column
=
"password"
),
@Result
(
property
=
"salt"
,
column
=
"salt"
),
@Result
(
property
=
"state"
,
column
=
"state"
),
@Result
(
property
=
"roleList"
,
javaType
=
List
.
class
,
column
=
"id"
,
many
=
@Many
(
select
=
"com.yxproject.start.mapper.SysRoleMapper.selectRoleByUserId"
))})
public
UserInfo
selectUserInfoByUserId
(
@Param
(
"userId"
)
Integer
userId
);
/**
/**
* 删除用户
* 删除用户
* @param userId
* @param userId
*/
*/
@Update
(
"UPDATE
FROM
USER_INFO SET STATE = 1 WHERE ID=#{userId}"
)
@Update
(
"UPDATE USER_INFO SET STATE = 1 WHERE ID=#{userId}"
)
public
void
delUserInfo
(
@Param
(
"userId"
)
Integer
userId
);
public
void
delUserInfo
(
@Param
(
"userId"
)
Integer
userId
);
/**
* 启用用户
* @param userId
*/
@Update
(
"UPDATE USER_INFO SET STATE = 0 WHERE ID=#{userId}"
)
public
void
backUserInfo
(
@Param
(
"userId"
)
Integer
userId
);
/**
* 更新用户
* @param userInfo
*/
@Update
(
"UPDATE USER_INFO SET USERNAME=#{username},NAME=#{name} where ID=#{id}"
)
public
void
updateUserInfo
(
UserInfo
userInfo
);
public
void
updateUserInfo
(
UserInfo
userInfo
);
}
}
src/main/java/com/yxproject/start/service/SysPermissionService.java
View file @
84046ca5
...
@@ -21,11 +21,24 @@ public interface SysPermissionService {
...
@@ -21,11 +21,24 @@ public interface SysPermissionService {
*/
*/
public
List
<
SysPermission
>
getAllPermission
();
public
List
<
SysPermission
>
getAllPermission
();
/**
* 查询所有可用权限
* @return
*/
public
List
<
SysPermission
>
getAllActivePermission
();
/**
/**
* 删除权限
* 删除权限
* @param permissionId
* @param permissionId
* @return
* @return
*/
*/
public
boolean
deletePermission
(
Integer
permissionId
);
public
boolean
deletePermission
(
Integer
permissionId
);
/**
* 启用权限
* @param permissionId
* @return
*/
public
boolean
backPermission
(
Integer
permissionId
);
}
}
src/main/java/com/yxproject/start/service/SysRoleService.java
View file @
84046ca5
...
@@ -16,6 +16,14 @@ public interface SysRoleService {
...
@@ -16,6 +16,14 @@ public interface SysRoleService {
*/
*/
public
boolean
addRole
(
SysRole
sysRole
,
String
[]
ids
);
public
boolean
addRole
(
SysRole
sysRole
,
String
[]
ids
);
/**
* 修改角色和权限
* @param sysRole
* @param ids
* @return
*/
// public boolean updateRole(SysRole sysRole,String[] ids,String[] oldIds);
/**
/**
* 查询所有角色
* 查询所有角色
* @return
* @return
...
@@ -34,4 +42,18 @@ public interface SysRoleService {
...
@@ -34,4 +42,18 @@ public interface SysRoleService {
* @return
* @return
*/
*/
public
boolean
deleteRole
(
Integer
roleId
);
public
boolean
deleteRole
(
Integer
roleId
);
/**
* 启用角色
* @param roleId
* @return
*/
public
boolean
backRole
(
Integer
roleId
);
/**
* 通过角色id查询角色和权限
* @param roleId
* @return
*/
public
SysRole
getRoleByRoleId
(
Integer
roleId
);
}
}
src/main/java/com/yxproject/start/service/UserInfoService.java
View file @
84046ca5
...
@@ -2,6 +2,7 @@ package com.yxproject.start.service;
...
@@ -2,6 +2,7 @@ package com.yxproject.start.service;
import
com.yxproject.start.entity.UserInfo
;
import
com.yxproject.start.entity.UserInfo
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -29,6 +30,29 @@ public interface UserInfoService{
...
@@ -29,6 +30,29 @@ public interface UserInfoService{
* @return
* @return
*/
*/
public
boolean
deleteUserInfo
(
Integer
userId
);
public
boolean
deleteUserInfo
(
Integer
userId
);
/**
* 启用用户
* @param userId
* @return
*/
public
boolean
BackUserInfo
(
Integer
userId
);
/**
* 通过用户id查询用户和角色
* @param userId
* @return
*/
public
UserInfo
getUserInfoByUserId
(
Integer
userId
);
/**
* 更新用户
* @param userInfo
* @param roleId
* @return
*/
public
boolean
updateUser
(
UserInfo
userInfo
,
Integer
roleId
,
Integer
oldRoleId
);
// int delUsername( UserInfo userInfo);
// int delUsername( UserInfo userInfo);
// int updateUsername(UserInfo userInfo);
// int updateUsername(UserInfo userInfo);
}
}
src/main/java/com/yxproject/start/service/impl/SysPermissionServiceImpl.java
View file @
84046ca5
...
@@ -24,6 +24,11 @@ public class SysPermissionServiceImpl implements SysPermissionService{
...
@@ -24,6 +24,11 @@ public class SysPermissionServiceImpl implements SysPermissionService{
return
true
;
return
true
;
}
}
@Override
public
List
<
SysPermission
>
getAllActivePermission
()
{
List
<
SysPermission
>
list
=
sysPermissionMapper
.
selectAllActivePermission
();
return
list
;
}
@Override
@Override
public
List
<
SysPermission
>
getAllPermission
()
{
public
List
<
SysPermission
>
getAllPermission
()
{
List
<
SysPermission
>
list
=
sysPermissionMapper
.
selectAllPermission
();
List
<
SysPermission
>
list
=
sysPermissionMapper
.
selectAllPermission
();
...
@@ -37,5 +42,11 @@ public class SysPermissionServiceImpl implements SysPermissionService{
...
@@ -37,5 +42,11 @@ public class SysPermissionServiceImpl implements SysPermissionService{
return
true
;
return
true
;
}
}
@Override
public
boolean
backPermission
(
Integer
permissionId
)
{
sysPermissionMapper
.
backPermission
(
permissionId
);
return
true
;
}
}
}
src/main/java/com/yxproject/start/service/impl/SysRoleServiceImpl.java
View file @
84046ca5
...
@@ -31,34 +31,42 @@ public class SysRoleServiceImpl implements SysRoleService {
...
@@ -31,34 +31,42 @@ public class SysRoleServiceImpl implements SysRoleService {
return
true
;
return
true
;
}
}
// @Override
// @Transactional(rollbackFor=Exception.class)
// public boolean updateRole(SysRole sysRole,String[] ids,String[] oldIds){
// sysRoleMapper.updateRole(sysRole);
// return true;
// }
@Override
@Override
public
List
<
SysRole
>
getAllRoleInfo
()
{
public
List
<
SysRole
>
getAllRoleInfo
()
{
List
<
SysRole
>
list
=
sysRoleMapper
.
selectAllRole
();
List
<
SysRole
>
list
=
sysRoleMapper
.
selectAllRole
();
return
list
;
return
list
;
}
}
/**
* 查询所有可用的角色
*
* @return
*/
@Override
@Override
public
List
<
SysRole
>
getAllActiveRoleInfo
()
{
public
List
<
SysRole
>
getAllActiveRoleInfo
()
{
List
<
SysRole
>
list
=
sysRoleMapper
.
selectAllActiveRole
();
List
<
SysRole
>
list
=
sysRoleMapper
.
selectAllActiveRole
();
return
list
;
return
list
;
}
}
/**
* 删除角色
*
* @param roleId
* @return
*/
@Override
@Override
public
boolean
deleteRole
(
Integer
roleId
)
{
public
boolean
deleteRole
(
Integer
roleId
)
{
sysRoleMapper
.
delRole
(
roleId
);
sysRoleMapper
.
delRole
(
roleId
);
return
true
;
return
true
;
}
}
@Override
public
boolean
backRole
(
Integer
roleId
)
{
sysRoleMapper
.
backRole
(
roleId
);
return
true
;
}
@Override
public
SysRole
getRoleByRoleId
(
Integer
roleId
)
{
SysRole
sysRole
=
sysRoleMapper
.
selectRoleByRoleId
(
roleId
);
return
sysRole
;
}
}
}
src/main/java/com/yxproject/start/service/impl/UserInfoServiceImpl.java
View file @
84046ca5
...
@@ -2,12 +2,15 @@ package com.yxproject.start.service.impl;
...
@@ -2,12 +2,15 @@ package com.yxproject.start.service.impl;
import
com.yxproject.start.entity.UserInfo
;
import
com.yxproject.start.entity.UserInfo
;
import
com.yxproject.start.mapper.LoginMapper
;
import
com.yxproject.start.mapper.LoginMapper
;
import
com.yxproject.start.mapper.SysRoleMapper
;
import
com.yxproject.start.mapper.UserInfoMapper
;
import
com.yxproject.start.mapper.UserInfoMapper
;
import
com.yxproject.start.service.UserInfoService
;
import
com.yxproject.start.service.UserInfoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -19,6 +22,8 @@ public class UserInfoServiceImpl implements UserInfoService {
...
@@ -19,6 +22,8 @@ public class UserInfoServiceImpl implements UserInfoService {
@Autowired
@Autowired
private
UserInfoMapper
userInfoMapper
;
private
UserInfoMapper
userInfoMapper
;
@Autowired
private
SysRoleMapper
sysRoleMapper
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
@@ -39,7 +44,30 @@ public class UserInfoServiceImpl implements UserInfoService {
...
@@ -39,7 +44,30 @@ public class UserInfoServiceImpl implements UserInfoService {
@Override
@Override
public
boolean
deleteUserInfo
(
Integer
userId
)
{
public
boolean
deleteUserInfo
(
Integer
userId
)
{
userInfoMapper
.
delUserInfo
(
userId
);
return
true
;
}
@Override
public
boolean
BackUserInfo
(
Integer
userId
)
{
userInfoMapper
.
backUserInfo
(
userId
);
return
true
;
}
@Override
public
UserInfo
getUserInfoByUserId
(
Integer
userId
)
{
UserInfo
userInfo
=
userInfoMapper
.
selectUserInfoByUserId
(
userId
);
return
userInfo
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
updateUser
(
UserInfo
userInfo
,
Integer
roleId
,
Integer
oldRoleId
)
{
userInfoMapper
.
updateUserInfo
(
userInfo
);
if
(
roleId
.
equals
(
oldRoleId
)){
return
true
;
}
sysRoleMapper
.
updateUserRole
(
userInfo
.
getId
(),
roleId
);
return
true
;
return
true
;
}
}
//
//
...
...
src/main/resources/templates/index.html
View file @
84046ca5
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<body>
<body>
<!-- 顶部开始 -->
<!-- 顶部开始 -->
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"logo"
><a
href=
"/index"
>
Admin
</a></div>
<div
class=
"logo"
><a
href=
"/index"
>
用户权限后台管理系统
</a></div>
<!--<div class="left_open">-->
<!--<div class="left_open">-->
<!--<i title="展开左侧栏" class="layui-icon"></i>-->
<!--<i title="展开左侧栏" class="layui-icon"></i>-->
<!--</div>-->
<!--</div>-->
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
<!-- 中部结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<!-- 底部开始 -->
<div
class=
"footer"
>
<div
class=
"footer"
>
<div
class=
"copyright"
>
国投盈信秦皇岛科技有限公司 Copyright ©201
7
All Rights Reserved
</div>
<div
class=
"copyright"
>
国投盈信秦皇岛科技有限公司 Copyright ©201
8
All Rights Reserved
</div>
</div>
</div>
<!-- 底部结束 -->
<!-- 底部结束 -->
...
...
src/main/resources/templates/login.html
View file @
84046ca5
...
@@ -34,14 +34,14 @@
...
@@ -34,14 +34,14 @@
<label
class=
"col-xs-3 control-label"
>
用户名
</label>
<label
class=
"col-xs-3 control-label"
>
用户名
</label>
<div
class=
"col-xs-9"
>
<div
class=
"col-xs-9"
>
<input
type=
"text"
class=
"form-control"
id=
"yhid"
<input
type=
"text"
class=
"form-control"
id=
"yhid"
name=
"username"
placeholder=
"请输入用户名称"
>
name=
"username"
value=
"admin"
placeholder=
"请输入用户名称"
>
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
class=
"col-xs-3 control-label"
>
密码
</label>
<label
class=
"col-xs-3 control-label"
>
密码
</label>
<div
class=
"col-xs-9"
>
<div
class=
"col-xs-9"
>
<input
type=
"password"
class=
"form-control"
id=
"passid"
<input
type=
"password"
class=
"form-control"
id=
"passid"
name=
"password"
placeholder=
"请输入密码"
>
name=
"password"
value=
"123456"
placeholder=
"请输入密码"
>
</div>
</div>
</div>
</div>
...
...
src/main/resources/templates/permissionInfo.html
0 → 100644
View file @
84046ca5
<!DOCTYPE html>
<html
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
用户管理页面
</title>
<link
rel=
"stylesheet"
th:href=
"@{/css/font.css}"
>
<link
rel=
"stylesheet"
th:href=
"@{/css/xadmin.css}"
>
<link
rel=
"stylesheet"
th:href=
"@{/lib/layui/css/layui.css}"
>
<script
type=
"text/javascript"
th:src=
"@{/js/jquery.min.js}"
></script>
<script
th:src=
"@{/lib/layui/layui.js}"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
th:src=
"@{/js/xadmin.js}"
></script>
<script
type=
"text/javascript"
th:src=
"@{/lib/layui/lay/modules/form.js}"
></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script th:src="@{/js/html5.min.js}"></script>
<script th:src="@{/js/respond.min.js}"></script>
<![endif]-->
</head>
<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>
<th>
路径
</th>
<th>
类型
</th>
<th>
父类id
</th>
<th>
父类id树
</th>
<th>
状态
</th>
<th>
操作
</th>
</tr>
</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>
<td><span
th:text=
"${permission.url}"
></span></td>
<td><span
th:text=
"${permission.resource_type}"
></span></td>
<td><span
th:text=
"${permission.parent_id}"
></span></td>
<td><span
th:text=
"${permission.parent_ids}"
></span></td>
<td
class=
"td-status"
>
<span
th:if=
"${permission.available}==1"
class=
"layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled"
>
已停用
</span>
<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-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>
</div>
<script>
layui
.
use
(
'laydate'
,
function
(){
var
laydate
=
layui
.
laydate
;
//执行一个laydate实例
laydate
.
render
({
elem
:
'#start'
//指定元素
});
//执行一个laydate实例
laydate
.
render
({
elem
:
'#end'
//指定元素
});
});
/*用户-停用*/
function
member_stop
(
obj
,
id
){
layer
.
confirm
(
'确认要停用吗?'
,
function
(
index
){
if
(
$
(
obj
).
attr
(
'title'
)
==
'启用'
){
//发异步把用户状态进行更改
$
(
obj
).
attr
(
'title'
,
'停用'
)
$
(
obj
).
find
(
'i'
).
html
(
''
);
$
(
obj
).
parents
(
"tr"
).
find
(
".td-status"
).
find
(
'span'
).
addClass
(
'layui-btn-disabled'
).
html
(
'已停用'
);
layer
.
msg
(
'已停用!'
,{
icon
:
5
,
time
:
1000
});
}
else
{
$
(
obj
).
attr
(
'title'
,
'启用'
)
$
(
obj
).
find
(
'i'
).
html
(
''
);
$
(
obj
).
parents
(
"tr"
).
find
(
".td-status"
).
find
(
'span'
).
removeClass
(
'layui-btn-disabled'
).
html
(
'已启用'
);
layer
.
msg
(
'已启用!'
,{
icon
:
5
,
time
:
1000
});
}
});
}
/*用户-删除*/
function
member_del
(
obj
,
id
){
layer
.
confirm
(
'确认要删除吗?'
,
function
(
index
){
//发异步删除数据
$
(
obj
).
parents
(
"tr"
).
remove
();
layer
.
msg
(
'已删除!'
,{
icon
:
1
,
time
:
1000
});
});
}
function
delAll
(
argument
)
{
var
data
=
tableCheck
.
getData
();
layer
.
confirm
(
'确认要删除吗?'
+
data
,
function
(
index
){
//捉到所有被选中的,发异步进行删除
layer
.
msg
(
'删除成功'
,
{
icon
:
1
});
$
(
".layui-form-checked"
).
not
(
'.header'
).
parents
(
'tr'
).
remove
();
});
}
function
del
()
{
if
(
confirm
(
"您确定要删除吗?"
))
{
return
true
;
}
else
{
return
false
;
}
}
</script>
</body>
</html>
\ No newline at end of file
src/main/resources/templates/roleInfo.html
0 → 100644
View file @
84046ca5
<!DOCTYPE html>
<html
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
用户管理页面
</title>
<link
rel=
"stylesheet"
th:href=
"@{/css/font.css}"
>
<link
rel=
"stylesheet"
th:href=
"@{/css/xadmin.css}"
>
<link
rel=
"stylesheet"
th:href=
"@{/lib/layui/css/layui.css}"
>
<script
type=
"text/javascript"
th:src=
"@{/js/jquery.min.js}"
></script>
<script
th:src=
"@{/lib/layui/layui.js}"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
th:src=
"@{/js/xadmin.js}"
></script>
<script
type=
"text/javascript"
th:src=
"@{/lib/layui/lay/modules/form.js}"
></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script th:src="@{/js/html5.min.js}"></script>
<script th:src="@{/js/respond.min.js}"></script>
<![endif]-->
</head>
<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>
<th>
权限
</th>
<th>
状态
</th>
<th>
操作
</th>
</tr>
</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>
<td><span
th:each=
"permission:${role.permissions}"
>
<span
th:text=
"${permission.name}"
></span>
</span>
</td>
<td
class=
"td-status"
>
<span
th:if=
"${role.available}==1"
class=
"layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled"
>
已停用
</span>
<span
th:if=
"${role.available}==0"
class=
"layui-btn layui-btn-normal layui-btn-mini"
>
已启用
</span>
</td>
<td>
<a
class=
"layui-btn layui-btn"
href=
"#"
th:href=
"@{/updateRoleInfo(roleId=${role.id})}"
>
修改
</a>
<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>
</div>
<script>
layui
.
use
(
'laydate'
,
function
(){
var
laydate
=
layui
.
laydate
;
//执行一个laydate实例
laydate
.
render
({
elem
:
'#start'
//指定元素
});
//执行一个laydate实例
laydate
.
render
({
elem
:
'#end'
//指定元素
});
});
/*用户-停用*/
function
member_stop
(
obj
,
id
){
layer
.
confirm
(
'确认要停用吗?'
,
function
(
index
){
if
(
$
(
obj
).
attr
(
'title'
)
==
'启用'
){
//发异步把用户状态进行更改
$
(
obj
).
attr
(
'title'
,
'停用'
)
$
(
obj
).
find
(
'i'
).
html
(
''
);
$
(
obj
).
parents
(
"tr"
).
find
(
".td-status"
).
find
(
'span'
).
addClass
(
'layui-btn-disabled'
).
html
(
'已停用'
);
layer
.
msg
(
'已停用!'
,{
icon
:
5
,
time
:
1000
});
}
else
{
$
(
obj
).
attr
(
'title'
,
'启用'
)
$
(
obj
).
find
(
'i'
).
html
(
''
);
$
(
obj
).
parents
(
"tr"
).
find
(
".td-status"
).
find
(
'span'
).
removeClass
(
'layui-btn-disabled'
).
html
(
'已启用'
);
layer
.
msg
(
'已启用!'
,{
icon
:
5
,
time
:
1000
});
}
});
}
/*用户-删除*/
function
member_del
(
obj
,
id
){
layer
.
confirm
(
'确认要删除吗?'
,
function
(
index
){
//发异步删除数据
$
(
obj
).
parents
(
"tr"
).
remove
();
layer
.
msg
(
'已删除!'
,{
icon
:
1
,
time
:
1000
});
});
}
function
delAll
(
argument
)
{
var
data
=
tableCheck
.
getData
();
layer
.
confirm
(
'确认要删除吗?'
+
data
,
function
(
index
){
//捉到所有被选中的,发异步进行删除
layer
.
msg
(
'删除成功'
,
{
icon
:
1
});
$
(
".layui-form-checked"
).
not
(
'.header'
).
parents
(
'tr'
).
remove
();
});
}
function
del
()
{
if
(
confirm
(
"您确定要删除吗?"
))
{
return
true
;
}
else
{
return
false
;
}
}
</script>
</body>
</html>
\ No newline at end of file
src/main/resources/templates/updateRoleInfo.html
0 → 100644
View file @
84046ca5
<!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/roleInfoUpdate}"
method=
"post"
>
<p><input
type=
"hidden"
name=
"roleId"
th:value=
"${sysRole.id}"
/></p>
<p
th:each=
"permission:${sysRole.permissions}"
>
<input
type=
"hidden"
name=
"permissionIds"
th:value=
"${permission.id}"
/>
</p>
<p>
角色名称:
<input
type=
"text"
name=
"role"
th:value=
"${sysRole.role}"
/></p>
<p>
角色描述:
<input
type=
"text"
name=
"description"
th:value=
"${sysRole.description}"
/></p>
<!--<p><input type="hidden" name="permissions"/></p>-->
<p>
分配权限:
<span
th:each=
"permList:${permissionList}"
>
<input
type=
"checkbox"
th:name=
"permissions"
th:value=
"${permList.id}"
><span
th:text=
"${permList.name}"
></span>
</span>
</p>
<p><input
type=
"submit"
value=
"添加"
/></p>
</form>
</body>
</html>
\ No newline at end of file
src/main/resources/templates/updateUserInfo.html
0 → 100644
View file @
84046ca5
<!DOCTYPE html>
<html
lang=
"en"
xmlns:th=
"http://www.w3.org/1999/xhtml"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Add
</title>
</head>
<link
rel=
"stylesheet"
th:href=
"@{/css/font.css}"
>
<link
rel=
"stylesheet"
th:href=
"@{/css/xadmin.css}"
>
<link
rel=
"stylesheet"
th:href=
"@{/lib/layui/css/layui.css}"
>
<script
type=
"text/javascript"
th:src=
"@{/js/jquery.min.js}"
></script>
<script
th:src=
"@{/lib/layui/layui.js}"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
th:src=
"@{/js/xadmin.js}"
></script>
<script
type=
"text/javascript"
th:src=
"@{/lib/layui/lay/modules/form.js}"
></script>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script th:src="@{/js/html5.min.js}"></script>
<script th:src="@{/js/respond.min.js}"></script>
<![endif]-->
<body>
<!--<h3>用户添加界面</h3>-->
<!--<form th:action="@{rest/user/userInfoAdd}" method="post">-->
<!--<p>用户名:<input type="text" name="username" value="用户名"/></p>-->
<!--<p>名称:<input type="text" name="name" value="会员"/></p>-->
<!--<p>密码:<input type="password" name="password" value="123456"/></p>-->
<!--<p>角色:<select name="roleId">-->
<!--<!–<option value="-1">不分配角色</option>–>-->
<!--<option th:each="roleList:${roleList}" th:value="${roleList.id}">-->
<!--<span th:text="${roleList.role}"></span>-->
<!--</option>-->
<!--</select>-->
<!--</p>-->
<!--<p><input type="submit" value="添加"/></p>-->
<!--</form>-->
<div
class=
"x-body layui-anim layui-anim-up"
>
<form
class=
"layui-form"
th:action=
"@{rest/user/userInfoUpdate}"
method=
"post"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-input-inline"
>
<input
type=
"hidden"
name=
"userId"
required=
""
th:value=
"${userInfo.id}"
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-input-inline"
th:each=
"role:${userInfo.roleList}"
>
<input
type=
"hidden"
name=
"oldRoleId"
required=
""
th:value=
"${role.id}"
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
for=
"L_username"
class=
"layui-form-label"
>
<span
class=
"x-red"
>
*
</span>
用户名
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"L_username"
name=
"username"
required=
""
th:value=
"${userInfo.username}"
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
for=
"L_name"
class=
"layui-form-label"
>
<span
class=
"x-red"
>
*
</span>
昵称
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
id=
"L_name"
name=
"name"
required=
""
lay-verify=
"name"
th:value=
"${userInfo.name}"
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
for=
"role"
class=
"layui-form-label"
>
<span
class=
"x-red"
>
*
</span>
角色
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"roleId"
id=
"role"
>
<option
th:each=
"roleList:${roleList}"
th:value=
"${roleList.id}"
>
<span
style=
"text-align: left"
th:text=
"${roleList.role}"
></span>
</option>
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<input
type=
"submit"
class=
"layui-btn"
value=
"修改"
/>
</div>
</form>
</div>
<script>
layui
.
use
([
'form'
,
'layer'
],
function
(){
$
=
layui
.
jquery
;
var
form
=
layui
.
form
,
layer
=
layui
.
layer
;
//自定义验证规则
form
.
verify
({
pass
:
[
/
(
.+
){6,12}
$/
,
'密码必须6到12位'
]
,
repass
:
function
(
value
){
if
(
$
(
'#L_pass'
).
val
()
!=
$
(
'#L_repass'
).
val
()){
return
'两次密码不一致'
;
}
}
});
});
</script>
</body>
</html>
\ No newline at end of file
src/main/resources/templates/userInfo.html
View file @
84046ca5
...
@@ -35,25 +35,31 @@
...
@@ -35,25 +35,31 @@
<th>
ID
</th>
<th>
ID
</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=
"userInfo:${userInfo}"
>
<tr
th:each=
"userInfo:${userInfo
List
}"
>
<td>
<td>
<div
class=
"layui-unselect layui-form-checkbox"
lay-skin=
"primary"
data-id=
'2'
><i
class=
"layui-icon"
>

</i></div>
<div
class=
"layui-unselect layui-form-checkbox"
lay-skin=
"primary"
data-id=
'2'
><i
class=
"layui-icon"
>

</i></div>
</td>
</td>
<td><span
th:text=
"${userInfo.id}"
></span></td>
<td><span
th:text=
"${userInfo.id}"
></span></td>
<td><span
th:text=
"${userInfo.username}"
></span></td>
<td><span
th:text=
"${userInfo.username}"
></span></td>
<td><span
th:text=
"${userInfo.name}"
></span></td>
<td><span
th:text=
"${userInfo.name}"
></span></td>
<td><span
th:each=
"role:${userInfo.roleList}"
>
<span
th:text=
"${role.role}"
></span>
</span>
</td>
<td
class=
"td-status"
>
<td
class=
"td-status"
>
<span
th:if=
"${userInfo.state}==1"
class=
"layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled"
>
已停用
</span>
<span
th:if=
"${userInfo.state}==1"
class=
"layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled"
>
已停用
</span>
<span
th:if=
"${userInfo.state}==0"
class=
"layui-btn layui-btn-normal layui-btn-mini"
>
已启用
</span>
<span
th:if=
"${userInfo.state}==0"
class=
"layui-btn layui-btn-normal layui-btn-mini"
>
已启用
</span>
</td>
</td>
<td>
<td>
<a
class=
"layui-btn layui-btn"
href=
"/updateUserInfo/${userInfo.id}"
>
修改
</a>
<a
class=
"layui-btn layui-btn"
href=
"#"
th:href=
"@{updateUserInfo(userId=${userInfo.id})}"
>
修改
</a>
<a
class=
"layui-btn layui-btn-danger"
href=
"/delUserInfo/${userInfo.id}"
>
删除
</a>
<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>
<!--<td class="td-manage">-->
<!--<td class="td-manage">-->
<!--<a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">-->
<!--<a onclick="member_stop(this,'10001')" href="javascript:;" title="启用">-->
...
@@ -134,6 +140,15 @@
...
@@ -134,6 +140,15 @@
$
(
".layui-form-checked"
).
not
(
'.header'
).
parents
(
'tr'
).
remove
();
$
(
".layui-form-checked"
).
not
(
'.header'
).
parents
(
'tr'
).
remove
();
});
});
}
}
function
del
()
{
if
(
confirm
(
"您确定要删除吗?"
))
{
return
true
;
}
else
{
return
false
;
}
}
</script>
</script>
</body>
</body>
...
...
src/main/resources/templates/userInfoAdd.html
View file @
84046ca5
...
@@ -77,9 +77,9 @@
...
@@ -77,9 +77,9 @@
<span
class=
"x-red"
>
*
</span>
角色
<span
class=
"x-red"
>
*
</span>
角色
</label>
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<select
name=
"roleId"
id=
"role"
>
<select
name=
"roleId"
id=
"role"
>
<option
th:each=
"roleList:${activeRoleList}"
th:value=
"${roleList.id}"
>
<option
th:each=
"roleList:${activeRoleList}"
th:value=
"${roleList.id}"
>
<span
th:text=
"${roleList.role}"
></span>
<span
style=
"text-align: left"
th:text=
"${roleList.role}"
></span>
</option>
</option>
</select>
</select>
</div>
</div>
...
...
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