Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-shiro
Overview
Overview
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
常超
xzxt-shiro
Commits
81fadc09
Commit
81fadc09
authored
Jul 19, 2018
by
liuyongshuai
Committed by
liuyongshuai
Jul 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交角色的controller
parent
7ea8cfca
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
139 additions
and
0 deletions
+139
-0
src/main/java/com/xzxtshiro/controller/admin/SysRoleController.java
+139
-0
No files found.
src/main/java/com/xzxtshiro/controller/admin/SysRoleController.java
0 → 100644
View file @
81fadc09
package
com
.
xzxtshiro
.
controller
.
admin
;
import
com.xzxtshiro.pojo.BaseModel
;
import
com.xzxtshiro.pojo.SysRole
;
import
com.xzxtshiro.service.SysPermissionNewService
;
import
com.xzxtshiro.service.SysRoleService
;
import
net.sf.json.JSONArray
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author liuys
* @desc
* @date 2018-06-27 10:31
*/
@Controller
@RequestMapping
(
value
=
"/admin/role"
)
public
class
SysRoleController
{
@Autowired
private
SysRoleService
sysRoleService
;
@Autowired
private
SysPermissionNewService
sysPermissionService
;
/**
* 跳转到角色列表
*
* @return
*/
@RequestMapping
(
value
=
"/index"
,
method
=
RequestMethod
.
GET
)
public
String
index
(
String
msg
,
Model
model
)
{
/*if (msg != null && msg != "") {
model.addAttribute("msg", "角色添加成功!");
}*/
return
"admin/role/list"
;
}
/**
* 根据条件获取角色列表
*
* @param
* @return
*/
@ResponseBody
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
public
BaseModel
list
(
SysRole
role
)
{
return
sysRoleService
.
selectSysRolePage
(
role
);
}
/**
* 跳转到角色添加页面
*
* @param model
* @return
*/
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
GET
)
public
String
addIndex
(
Model
model
)
{
/**所有的权限*/
JSONArray
json
=
sysPermissionService
.
selectAllPermissions
();
model
.
addAttribute
(
"permission"
,
json
);
/**获取所有的角色*/
JSONArray
rolejson
=
sysRoleService
.
selectSysRolesByCondition
(
null
);
model
.
addAttribute
(
"role"
,
rolejson
);
return
"admin/role/add"
;
}
/**
* 添加角色---提交
*
* @param
* @param model
* @return
*/
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
public
String
add
(
SysRole
role
,
Model
model
)
{
System
.
out
.
println
(
"type.................................="
+
role
.
getType
());
SysRole
add
=
sysRoleService
.
add
(
role
);
return
"redirect:/admin/role/index?msg=success"
;
}
/**
* 跳转到角色修改页面
*
* @param
* @param model
* @return
*/
@RequestMapping
(
value
=
"/update/{roleId}"
,
method
=
RequestMethod
.
GET
)
public
String
updateIndex
(
@PathVariable
(
"roleId"
)
String
roleId
,
Model
model
)
{
Map
<
String
,
Object
>
roleMap
=
sysRoleService
.
selectSysRoleById
(
roleId
);
/**所有的权限*/
JSONArray
json
=
sysPermissionService
.
selectAllPermissions
();
/**获取所有的角色*/
JSONArray
rolejson
=
sysRoleService
.
selectSysRolesByCondition
(
null
);
model
.
addAttribute
(
"AllPermission"
,
json
);
model
.
addAttribute
(
"oldPermission"
,
roleMap
.
get
(
"oldPermission"
));
model
.
addAttribute
(
"AllRole"
,
rolejson
);
model
.
addAttribute
(
"role"
,
roleMap
.
get
(
"role"
));
return
"admin/role/update"
;
}
/**
* 更新角色,删除授权并重新进行授权
* @param role
* @param model
* @return
*/
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
public
String
update
(
SysRole
role
,
Model
model
)
{
SysRole
update
=
sysRoleService
.
update
(
role
);
return
"redirect:/admin/role/index?msg=success"
;
}
/**
* 删除角色,并删除授权
* @param sysRole
* @return
*/
@ResponseBody
@RequestMapping
(
value
=
"/deleteRoleById"
,
method
=
RequestMethod
.
POST
)
public
String
deleteRoleById
(
SysRole
sysRole
){
Integer
i
=
sysRoleService
.
deleteSysRoleById
(
sysRole
);
if
(
i
==
1
)
{
return
"success"
;
}
else
{
return
"error"
;
}
}
}
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