Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
612c4293
Commit
612c4293
authored
Jan 27, 2022
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户访问控制时校验数据权限,防止越权
parent
8007b22b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
3 deletions
+15
-3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
...va/com/ruoyi/web/controller/system/SysDeptController.java
+5
-3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
...va/com/ruoyi/web/controller/system/SysRoleController.java
+4
-0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
...va/com/ruoyi/web/controller/system/SysUserController.java
+4
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
+1
-0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+1
-0
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java
View file @
612c4293
...
...
@@ -125,16 +125,17 @@ public class SysDeptController extends BaseController
@PutMapping
public
AjaxResult
edit
(
@Validated
@RequestBody
SysDept
dept
)
{
Long
deptId
=
dept
.
getDeptId
();
deptService
.
checkDeptDataScope
(
deptId
);
if
(
UserConstants
.
NOT_UNIQUE
.
equals
(
deptService
.
checkDeptNameUnique
(
dept
)))
{
return
AjaxResult
.
error
(
"修改部门'"
+
dept
.
getDeptName
()
+
"'失败,部门名称已存在"
);
}
else
if
(
dept
.
getParentId
().
equals
(
dept
.
getDeptId
()
))
else
if
(
dept
.
getParentId
().
equals
(
dept
Id
))
{
return
AjaxResult
.
error
(
"修改部门'"
+
dept
.
getDeptName
()
+
"'失败,上级部门不能是自己"
);
}
else
if
(
StringUtils
.
equals
(
UserConstants
.
DEPT_DISABLE
,
dept
.
getStatus
())
&&
deptService
.
selectNormalChildrenDeptById
(
dept
.
getDeptId
())
>
0
)
else
if
(
StringUtils
.
equals
(
UserConstants
.
DEPT_DISABLE
,
dept
.
getStatus
())
&&
deptService
.
selectNormalChildrenDeptById
(
deptId
)
>
0
)
{
return
AjaxResult
.
error
(
"该部门包含未停用的子部门!"
);
}
...
...
@@ -158,6 +159,7 @@ public class SysDeptController extends BaseController
{
return
AjaxResult
.
error
(
"部门存在用户,不允许删除"
);
}
deptService
.
checkDeptDataScope
(
deptId
);
return
toAjax
(
deptService
.
deleteDeptById
(
deptId
));
}
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
View file @
612c4293
...
...
@@ -111,6 +111,7 @@ public class SysRoleController extends BaseController
public
AjaxResult
edit
(
@Validated
@RequestBody
SysRole
role
)
{
roleService
.
checkRoleAllowed
(
role
);
roleService
.
checkRoleDataScope
(
role
.
getRoleId
());
if
(
UserConstants
.
NOT_UNIQUE
.
equals
(
roleService
.
checkRoleNameUnique
(
role
)))
{
return
AjaxResult
.
error
(
"修改角色'"
+
role
.
getRoleName
()
+
"'失败,角色名称已存在"
);
...
...
@@ -145,6 +146,7 @@ public class SysRoleController extends BaseController
public
AjaxResult
dataScope
(
@RequestBody
SysRole
role
)
{
roleService
.
checkRoleAllowed
(
role
);
roleService
.
checkRoleDataScope
(
role
.
getRoleId
());
return
toAjax
(
roleService
.
authDataScope
(
role
));
}
...
...
@@ -157,6 +159,7 @@ public class SysRoleController extends BaseController
public
AjaxResult
changeStatus
(
@RequestBody
SysRole
role
)
{
roleService
.
checkRoleAllowed
(
role
);
roleService
.
checkRoleDataScope
(
role
.
getRoleId
());
role
.
setUpdateBy
(
getUsername
());
return
toAjax
(
roleService
.
updateRoleStatus
(
role
));
}
...
...
@@ -236,6 +239,7 @@ public class SysRoleController extends BaseController
@PutMapping
(
"/authUser/selectAll"
)
public
AjaxResult
selectAuthUserAll
(
Long
roleId
,
Long
[]
userIds
)
{
roleService
.
checkRoleDataScope
(
roleId
);
return
toAjax
(
roleService
.
insertAuthUsers
(
roleId
,
userIds
));
}
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
View file @
612c4293
...
...
@@ -148,6 +148,7 @@ public class SysUserController extends BaseController
public
AjaxResult
edit
(
@Validated
@RequestBody
SysUser
user
)
{
userService
.
checkUserAllowed
(
user
);
userService
.
checkUserDataScope
(
user
.
getUserId
());
if
(
StringUtils
.
isNotEmpty
(
user
.
getPhonenumber
())
&&
UserConstants
.
NOT_UNIQUE
.
equals
(
userService
.
checkPhoneUnique
(
user
)))
{
...
...
@@ -186,6 +187,7 @@ public class SysUserController extends BaseController
public
AjaxResult
resetPwd
(
@RequestBody
SysUser
user
)
{
userService
.
checkUserAllowed
(
user
);
userService
.
checkUserDataScope
(
user
.
getUserId
());
user
.
setPassword
(
SecurityUtils
.
encryptPassword
(
user
.
getPassword
()));
user
.
setUpdateBy
(
getUsername
());
return
toAjax
(
userService
.
resetPwd
(
user
));
...
...
@@ -200,6 +202,7 @@ public class SysUserController extends BaseController
public
AjaxResult
changeStatus
(
@RequestBody
SysUser
user
)
{
userService
.
checkUserAllowed
(
user
);
userService
.
checkUserDataScope
(
user
.
getUserId
());
user
.
setUpdateBy
(
getUsername
());
return
toAjax
(
userService
.
updateUserStatus
(
user
));
}
...
...
@@ -227,6 +230,7 @@ public class SysUserController extends BaseController
@PutMapping
(
"/authRole"
)
public
AjaxResult
insertAuthRole
(
Long
userId
,
Long
[]
roleIds
)
{
userService
.
checkUserDataScope
(
userId
);
userService
.
insertUserAuth
(
userId
,
roleIds
);
return
success
();
}
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
View file @
612c4293
...
...
@@ -361,6 +361,7 @@ public class SysRoleServiceImpl implements ISysRoleService
for
(
Long
roleId
:
roleIds
)
{
checkRoleAllowed
(
new
SysRole
(
roleId
));
checkRoleDataScope
(
roleId
);
SysRole
role
=
selectRoleById
(
roleId
);
if
(
countUserRoleByRoleId
(
roleId
)
>
0
)
{
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
View file @
612c4293
...
...
@@ -482,6 +482,7 @@ public class SysUserServiceImpl implements ISysUserService
for
(
Long
userId
:
userIds
)
{
checkUserAllowed
(
new
SysUser
(
userId
));
checkUserDataScope
(
userId
);
}
// 删除用户与角色关联
userRoleMapper
.
deleteUserRole
(
userIds
);
...
...
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