update 修改时检查用户数据权限范围
This commit is contained in:
parent
31c2cfa53c
commit
0c438ad8e9
@ -10,7 +10,6 @@ import com.ruoyi.common.core.domain.entity.SysDept;
|
|||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
@ -179,15 +178,12 @@ public class SysDeptServiceImpl extends ServicePlusImpl<SysDeptMapper, SysDept,
|
|||||||
* @param deptId 部门id
|
* @param deptId 部门id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkDeptDataScope(Long deptId)
|
public void checkDeptDataScope(Long deptId) {
|
||||||
{
|
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
|
||||||
{
|
|
||||||
SysDept dept = new SysDept();
|
SysDept dept = new SysDept();
|
||||||
dept.setDeptId(deptId);
|
dept.setDeptId(deptId);
|
||||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||||
if (StringUtils.isEmpty(depts))
|
if (StringUtils.isEmpty(depts)) {
|
||||||
{
|
|
||||||
throw new ServiceException("没有权限访问部门数据!");
|
throw new ServiceException("没有权限访问部门数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,15 +184,12 @@ public class SysRoleServiceImpl extends ServicePlusImpl<SysRoleMapper, SysRole,
|
|||||||
* @param roleId 角色id
|
* @param roleId 角色id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkRoleDataScope(Long roleId)
|
public void checkRoleDataScope(Long roleId) {
|
||||||
{
|
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
|
||||||
{
|
|
||||||
SysRole role = new SysRole();
|
SysRole role = new SysRole();
|
||||||
role.setRoleId(roleId);
|
role.setRoleId(roleId);
|
||||||
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||||
if (StringUtils.isEmpty(roles))
|
if (StringUtils.isEmpty(roles)) {
|
||||||
{
|
|
||||||
throw new ServiceException("没有权限访问角色数据!");
|
throw new ServiceException("没有权限访问角色数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,15 +223,12 @@ public class SysUserServiceImpl extends ServicePlusImpl<SysUserMapper, SysUser,
|
|||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkUserDataScope(Long userId)
|
public void checkUserDataScope(Long userId) {
|
||||||
{
|
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
|
||||||
{
|
|
||||||
SysUser user = new SysUser();
|
SysUser user = new SysUser();
|
||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||||
if (StringUtils.isEmpty(users))
|
if (StringUtils.isEmpty(users)) {
|
||||||
{
|
|
||||||
throw new ServiceException("没有权限访问用户数据!");
|
throw new ServiceException("没有权限访问用户数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,9 @@
|
|||||||
<select id="selectPageRoleList" parameterType="SysRole" resultMap="SysRoleResult">
|
<select id="selectPageRoleList" parameterType="SysRole" resultMap="SysRoleResult">
|
||||||
<include refid="selectRoleVo"/>
|
<include refid="selectRoleVo"/>
|
||||||
where r.del_flag = '0'
|
where r.del_flag = '0'
|
||||||
|
<if test="role.roleId != null and role.roleId != 0">
|
||||||
|
AND r.role_id = #{role.roleId}
|
||||||
|
</if>
|
||||||
<if test="role.roleName != null and role.roleName != ''">
|
<if test="role.roleName != null and role.roleName != ''">
|
||||||
AND r.role_name like concat('%', #{role.roleName}, '%')
|
AND r.role_name like concat('%', #{role.roleName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -86,6 +86,9 @@
|
|||||||
sys_user u
|
sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
where u.del_flag = '0'
|
where u.del_flag = '0'
|
||||||
|
<if test="user.userId != null and user.userId != 0">
|
||||||
|
AND u.user_id = #{user.userId}
|
||||||
|
</if>
|
||||||
<if test="user.userName != null and user.userName != ''">
|
<if test="user.userName != null and user.userName != ''">
|
||||||
AND u.user_name like concat('%', #{user.userName}, '%')
|
AND u.user_name like concat('%', #{user.userName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user