From 338f661d41f7615cbcad95048c000535eee133d1 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 29 Jun 2020 11:44:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E7=94=A8=E6=88=B7=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E9=80=89=E6=8B=A9=E7=B3=BB=E7=BB=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi/sql/{ry_20200415.sql => ry_20200629.sql} | 4 ++-- .../ruoyi/project/system/controller/SysUserController.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) rename ruoyi/sql/{ry_20200415.sql => ry_20200629.sql} (98%) diff --git a/ruoyi/sql/ry_20200415.sql b/ruoyi/sql/ry_20200629.sql similarity index 98% rename from ruoyi/sql/ry_20200415.sql rename to ruoyi/sql/ry_20200629.sql index cf512472..7c8e8c87 100644 --- a/ruoyi/sql/ry_20200415.sql +++ b/ruoyi/sql/ry_20200629.sql @@ -120,8 +120,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', '普通角色'); -- ---------------------------- diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java index b93e8eb2..5c685700 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java @@ -1,6 +1,7 @@ package com.ruoyi.project.system.controller; import java.util.List; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -25,6 +26,7 @@ import com.ruoyi.framework.security.service.TokenService; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.project.system.domain.SysRole; import com.ruoyi.project.system.domain.SysUser; import com.ruoyi.project.system.service.ISysPostService; import com.ruoyi.project.system.service.ISysRoleService; @@ -101,7 +103,8 @@ public class SysUserController extends BaseController public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { AjaxResult ajax = AjaxResult.success(); - ajax.put("roles", roleService.selectRoleAll()); + List roles = roleService.selectRoleAll(); + ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); ajax.put("posts", postService.selectPostAll()); if (StringUtils.isNotNull(userId)) {