mirror of https://gitee.com/y_project/RuoYi.git
创建用户不允许选择系统管理员角色
parent
84e447e170
commit
68a4e6de5f
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -21,6 +22,7 @@ import com.ruoyi.common.enums.BusinessType;
|
|||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
|
@ -106,7 +108,7 @@ public class SysUserController extends BaseController
|
|||
@GetMapping("/add")
|
||||
public String add(ModelMap mmap)
|
||||
{
|
||||
mmap.put("roles", roleService.selectRoleAll());
|
||||
mmap.put("roles", roleService.selectRoleAll().stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
mmap.put("posts", postService.selectPostAll());
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
@ -144,8 +146,9 @@ public class SysUserController extends BaseController
|
|||
@GetMapping("/edit/{userId}")
|
||||
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||
{
|
||||
List<SysRole> roles = roleService.selectRolesByUserId(userId);
|
||||
mmap.put("user", userService.selectUserById(userId));
|
||||
mmap.put("roles", roleService.selectRolesByUserId(userId));
|
||||
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
mmap.put("posts", postService.selectPostsByUserId(userId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ create table sys_role (
|
|||
-- ----------------------------
|
||||
-- 初始化-角色信息表数据
|
||||
-- ----------------------------
|
||||
insert into sys_role values('1', '管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '管理员');
|
||||
insert into sys_role values('2', '普通角色', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '普通角色');
|
||||
insert into sys_role values('1', '系统管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统管理员');
|
||||
insert into sys_role values('2', '普通角色', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '普通角色');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
|
Loading…
Reference in New Issue