Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
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
yaru
fgqyxxlr
Commits
661b6fe5
Commit
661b6fe5
authored
Oct 03, 2019
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理员用户&角色不允许操作
parent
ac97d15a
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
83 additions
and
18 deletions
+83
-18
README.md
+1
-1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
+3
-0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
+5
-6
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
+0
-1
ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java
+0
-1
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java
+20
-0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java
+10
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java
+9
-1
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
+7
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
+14
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+14
-8
No files found.
README.md
View file @
661b6fe5
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
10.
登录日志:系统登录日志记录查询包含登录异常。
10.
登录日志:系统登录日志记录查询包含登录异常。
11.
在线用户:当前系统中活跃用户状态监控。
11.
在线用户:当前系统中活跃用户状态监控。
12.
定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
12.
定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
13.
代码生成:前后端代码的生成(java、html、xml、sql
)
支持CRUD下载 。
13.
代码生成:前后端代码的生成(java、html、xml、sql
)
支持CRUD下载 。
14.
系统接口:根据业务代码自动生成相关的api接口文档。
14.
系统接口:根据业务代码自动生成相关的api接口文档。
15.
服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
15.
服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
16.
在线构建器:拖动表单元素生成相应的HTML代码。
16.
在线构建器:拖动表单元素生成相应的HTML代码。
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
View file @
661b6fe5
...
@@ -121,6 +121,7 @@ public class SysRoleController extends BaseController
...
@@ -121,6 +121,7 @@ public class SysRoleController extends BaseController
@ResponseBody
@ResponseBody
public
AjaxResult
editSave
(
@Validated
SysRole
role
)
public
AjaxResult
editSave
(
@Validated
SysRole
role
)
{
{
roleService
.
checkRoleAllowed
(
role
);
if
(
UserConstants
.
ROLE_NAME_NOT_UNIQUE
.
equals
(
roleService
.
checkRoleNameUnique
(
role
)))
if
(
UserConstants
.
ROLE_NAME_NOT_UNIQUE
.
equals
(
roleService
.
checkRoleNameUnique
(
role
)))
{
{
return
error
(
"修改角色'"
+
role
.
getRoleName
()
+
"'失败,角色名称已存在"
);
return
error
(
"修改角色'"
+
role
.
getRoleName
()
+
"'失败,角色名称已存在"
);
...
@@ -153,6 +154,7 @@ public class SysRoleController extends BaseController
...
@@ -153,6 +154,7 @@ public class SysRoleController extends BaseController
@ResponseBody
@ResponseBody
public
AjaxResult
authDataScopeSave
(
SysRole
role
)
public
AjaxResult
authDataScopeSave
(
SysRole
role
)
{
{
roleService
.
checkRoleAllowed
(
role
);
role
.
setUpdateBy
(
ShiroUtils
.
getLoginName
());
role
.
setUpdateBy
(
ShiroUtils
.
getLoginName
());
if
(
roleService
.
authDataScope
(
role
)
>
0
)
if
(
roleService
.
authDataScope
(
role
)
>
0
)
{
{
...
@@ -216,6 +218,7 @@ public class SysRoleController extends BaseController
...
@@ -216,6 +218,7 @@ public class SysRoleController extends BaseController
@ResponseBody
@ResponseBody
public
AjaxResult
changeStatus
(
SysRole
role
)
public
AjaxResult
changeStatus
(
SysRole
role
)
{
{
roleService
.
checkRoleAllowed
(
role
);
return
toAjax
(
roleService
.
changeStatus
(
role
));
return
toAjax
(
roleService
.
changeStatus
(
role
));
}
}
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
View file @
661b6fe5
...
@@ -18,7 +18,6 @@ import com.ruoyi.common.core.controller.BaseController;
...
@@ -18,7 +18,6 @@ import com.ruoyi.common.core.controller.BaseController;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.framework.shiro.service.SysPasswordService
;
import
com.ruoyi.framework.shiro.service.SysPasswordService
;
import
com.ruoyi.framework.util.ShiroUtils
;
import
com.ruoyi.framework.util.ShiroUtils
;
...
@@ -159,11 +158,8 @@ public class SysUserController extends BaseController
...
@@ -159,11 +158,8 @@ public class SysUserController extends BaseController
@ResponseBody
@ResponseBody
public
AjaxResult
editSave
(
@Validated
SysUser
user
)
public
AjaxResult
editSave
(
@Validated
SysUser
user
)
{
{
if
(
StringUtils
.
isNotNull
(
user
.
getUserId
())
&&
SysUser
.
isAdmin
(
user
.
getUserId
()))
userService
.
checkUserAllowed
(
user
);
{
if
(
UserConstants
.
USER_PHONE_NOT_UNIQUE
.
equals
(
userService
.
checkPhoneUnique
(
user
)))
return
error
(
"不允许修改超级管理员用户"
);
}
else
if
(
UserConstants
.
USER_PHONE_NOT_UNIQUE
.
equals
(
userService
.
checkPhoneUnique
(
user
)))
{
{
return
error
(
"修改用户'"
+
user
.
getLoginName
()
+
"'失败,手机号码已存在"
);
return
error
(
"修改用户'"
+
user
.
getLoginName
()
+
"'失败,手机号码已存在"
);
}
}
...
@@ -190,6 +186,7 @@ public class SysUserController extends BaseController
...
@@ -190,6 +186,7 @@ public class SysUserController extends BaseController
@ResponseBody
@ResponseBody
public
AjaxResult
resetPwdSave
(
SysUser
user
)
public
AjaxResult
resetPwdSave
(
SysUser
user
)
{
{
userService
.
checkUserAllowed
(
user
);
user
.
setSalt
(
ShiroUtils
.
randomSalt
());
user
.
setSalt
(
ShiroUtils
.
randomSalt
());
user
.
setPassword
(
passwordService
.
encryptPassword
(
user
.
getLoginName
(),
user
.
getPassword
(),
user
.
getSalt
()));
user
.
setPassword
(
passwordService
.
encryptPassword
(
user
.
getLoginName
(),
user
.
getPassword
(),
user
.
getSalt
()));
if
(
userService
.
resetUserPwd
(
user
)
>
0
)
if
(
userService
.
resetUserPwd
(
user
)
>
0
)
...
@@ -258,6 +255,7 @@ public class SysUserController extends BaseController
...
@@ -258,6 +255,7 @@ public class SysUserController extends BaseController
@ResponseBody
@ResponseBody
public
AjaxResult
changeStatus
(
SysUser
user
)
public
AjaxResult
changeStatus
(
SysUser
user
)
{
{
userService
.
checkUserAllowed
(
user
);
return
toAjax
(
userService
.
changeStatus
(
user
));
return
toAjax
(
userService
.
changeStatus
(
user
));
}
}
}
}
\ No newline at end of file
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
View file @
661b6fe5
...
@@ -5,7 +5,6 @@ import java.util.ArrayList;
...
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.apache.ibatis.io.VFS
;
import
org.apache.ibatis.io.VFS
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/realm/UserRealm.java
View file @
661b6fe5
...
@@ -19,7 +19,6 @@ import org.apache.shiro.subject.PrincipalCollection;
...
@@ -19,7 +19,6 @@ import org.apache.shiro.subject.PrincipalCollection;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.ruoyi.common.exception.user.CaptchaException
;
import
com.ruoyi.common.exception.user.CaptchaException
;
import
com.ruoyi.common.exception.user.RoleBlockedException
;
import
com.ruoyi.common.exception.user.RoleBlockedException
;
import
com.ruoyi.common.exception.user.UserBlockedException
;
import
com.ruoyi.common.exception.user.UserBlockedException
;
...
...
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRole.java
View file @
661b6fe5
...
@@ -52,6 +52,16 @@ public class SysRole extends BaseEntity
...
@@ -52,6 +52,16 @@ public class SysRole extends BaseEntity
/** 部门组(数据权限) */
/** 部门组(数据权限) */
private
Long
[]
deptIds
;
private
Long
[]
deptIds
;
public
SysRole
()
{
}
public
SysRole
(
Long
roleId
)
{
this
.
roleId
=
roleId
;
}
public
Long
getRoleId
()
public
Long
getRoleId
()
{
{
return
roleId
;
return
roleId
;
...
@@ -62,6 +72,16 @@ public class SysRole extends BaseEntity
...
@@ -62,6 +72,16 @@ public class SysRole extends BaseEntity
this
.
roleId
=
roleId
;
this
.
roleId
=
roleId
;
}
}
public
boolean
isAdmin
()
{
return
isAdmin
(
this
.
roleId
);
}
public
static
boolean
isAdmin
(
Long
roleId
)
{
return
roleId
!=
null
&&
1L
==
roleId
;
}
public
String
getDataScope
()
public
String
getDataScope
()
{
{
return
dataScope
;
return
dataScope
;
...
...
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUser.java
View file @
661b6fe5
...
@@ -93,6 +93,16 @@ public class SysUser extends BaseEntity
...
@@ -93,6 +93,16 @@ public class SysUser extends BaseEntity
/** 岗位组 */
/** 岗位组 */
private
Long
[]
postIds
;
private
Long
[]
postIds
;
public
SysUser
()
{
}
public
SysUser
(
Long
userId
)
{
this
.
userId
=
userId
;
}
public
Long
getUserId
()
public
Long
getUserId
()
{
{
return
userId
;
return
userId
;
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java
View file @
661b6fe5
...
@@ -109,6 +109,13 @@ public interface ISysRoleService
...
@@ -109,6 +109,13 @@ public interface ISysRoleService
public
String
checkRoleKeyUnique
(
SysRole
role
);
public
String
checkRoleKeyUnique
(
SysRole
role
);
/**
/**
* 校验角色是否允许操作
*
* @param role 角色信息
*/
public
void
checkRoleAllowed
(
SysRole
role
);
/**
* 通过角色ID查询角色使用数量
* 通过角色ID查询角色使用数量
*
*
* @param roleId 角色ID
* @param roleId 角色ID
...
@@ -123,6 +130,7 @@ public interface ISysRoleService
...
@@ -123,6 +130,7 @@ public interface ISysRoleService
* @return 结果
* @return 结果
*/
*/
public
int
changeStatus
(
SysRole
role
);
public
int
changeStatus
(
SysRole
role
);
/**
/**
* 取消授权用户角色
* 取消授权用户角色
*
*
...
@@ -139,7 +147,7 @@ public interface ISysRoleService
...
@@ -139,7 +147,7 @@ public interface ISysRoleService
* @return 结果
* @return 结果
*/
*/
public
int
deleteAuthUsers
(
Long
roleId
,
String
userIds
);
public
int
deleteAuthUsers
(
Long
roleId
,
String
userIds
);
/**
/**
* 批量选择授权用户角色
* 批量选择授权用户角色
*
*
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
View file @
661b6fe5
...
@@ -140,6 +140,13 @@ public interface ISysUserService
...
@@ -140,6 +140,13 @@ public interface ISysUserService
public
String
checkEmailUnique
(
SysUser
user
);
public
String
checkEmailUnique
(
SysUser
user
);
/**
/**
* 校验用户是否允许操作
*
* @param user 用户信息
*/
public
void
checkUserAllowed
(
SysUser
user
);
/**
* 根据用户ID查询用户所属角色组
* 根据用户ID查询用户所属角色组
*
*
* @param userId 用户ID
* @param userId 用户ID
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
View file @
661b6fe5
...
@@ -150,6 +150,7 @@ public class SysRoleServiceImpl implements ISysRoleService
...
@@ -150,6 +150,7 @@ public class SysRoleServiceImpl implements ISysRoleService
Long
[]
roleIds
=
Convert
.
toLongArray
(
ids
);
Long
[]
roleIds
=
Convert
.
toLongArray
(
ids
);
for
(
Long
roleId
:
roleIds
)
for
(
Long
roleId
:
roleIds
)
{
{
checkRoleAllowed
(
new
SysRole
(
roleId
));
SysRole
role
=
selectRoleById
(
roleId
);
SysRole
role
=
selectRoleById
(
roleId
);
if
(
countUserRoleByRoleId
(
roleId
)
>
0
)
if
(
countUserRoleByRoleId
(
roleId
)
>
0
)
{
{
...
@@ -294,6 +295,19 @@ public class SysRoleServiceImpl implements ISysRoleService
...
@@ -294,6 +295,19 @@ public class SysRoleServiceImpl implements ISysRoleService
}
}
/**
/**
* 校验角色是否允许操作
*
* @param role 角色信息
*/
public
void
checkRoleAllowed
(
SysRole
role
)
{
if
(
StringUtils
.
isNotNull
(
role
.
getRoleId
())
&&
role
.
isAdmin
())
{
throw
new
BusinessException
(
"不允许操作超级管理员角色"
);
}
}
/**
* 通过角色ID查询角色使用数量
* 通过角色ID查询角色使用数量
*
*
* @param roleId 角色ID
* @param roleId 角色ID
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
View file @
661b6fe5
...
@@ -167,10 +167,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -167,10 +167,7 @@ public class SysUserServiceImpl implements ISysUserService
Long
[]
userIds
=
Convert
.
toLongArray
(
ids
);
Long
[]
userIds
=
Convert
.
toLongArray
(
ids
);
for
(
Long
userId
:
userIds
)
for
(
Long
userId
:
userIds
)
{
{
if
(
SysUser
.
isAdmin
(
userId
))
checkUserAllowed
(
new
SysUser
(
userId
));
{
throw
new
BusinessException
(
"不允许删除超级管理员用户"
);
}
}
}
return
userMapper
.
deleteUserByIds
(
userIds
);
return
userMapper
.
deleteUserByIds
(
userIds
);
}
}
...
@@ -346,6 +343,19 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -346,6 +343,19 @@ public class SysUserServiceImpl implements ISysUserService
}
}
/**
/**
* 校验用户是否允许操作
*
* @param user 用户信息
*/
public
void
checkUserAllowed
(
SysUser
user
)
{
if
(
StringUtils
.
isNotNull
(
user
.
getUserId
())
&&
user
.
isAdmin
())
{
throw
new
BusinessException
(
"不允许操作超级管理员用户"
);
}
}
/**
* 查询用户所属角色组
* 查询用户所属角色组
*
*
* @param userId 用户ID
* @param userId 用户ID
...
@@ -465,10 +475,6 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -465,10 +475,6 @@ public class SysUserServiceImpl implements ISysUserService
@Override
@Override
public
int
changeStatus
(
SysUser
user
)
public
int
changeStatus
(
SysUser
user
)
{
{
if
(
SysUser
.
isAdmin
(
user
.
getUserId
()))
{
throw
new
BusinessException
(
"不允许修改超级管理员用户"
);
}
return
userMapper
.
updateUser
(
user
);
return
userMapper
.
updateUser
(
user
);
}
}
}
}
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