mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-03-09 16:21:09 +08:00
fix 修复数据权限问题
This commit is contained in:
@@ -3,7 +3,6 @@ package com.ruoyi.framework.aspectj;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
@@ -19,6 +18,7 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据过滤处理
|
||||
@@ -145,10 +145,15 @@ public class DataScopeAspect
|
||||
if (StrUtil.isNotBlank(sqlString.toString()))
|
||||
{
|
||||
Object params = joinPoint.getArgs()[0];
|
||||
if (Validator.isNotNull(params) && params instanceof BaseEntity)
|
||||
if (Validator.isNotNull(params))
|
||||
{
|
||||
BaseEntity baseEntity = (BaseEntity) params;
|
||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||
try {
|
||||
Method getParams = params.getClass().getDeclaredMethod("getParams", null);
|
||||
Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null);
|
||||
invoke.put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,14 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
public List<SysDept> selectDeptList(SysDept dept);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
|
||||
@@ -12,6 +12,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public List<SysRole> selectRoleList(SysRole role);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
|
||||
@@ -48,15 +48,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysDept> selectDeptList(SysDept dept) {
|
||||
Object dataScope = dept.getParams().get("dataScope");
|
||||
return list(new LambdaQueryWrapper<SysDept>()
|
||||
.eq(dept.getParentId() != null && dept.getParentId() != 0,
|
||||
SysDept::getParentId, dept.getParentId())
|
||||
.like(StrUtil.isNotBlank(dept.getDeptName()), SysDept::getDeptName, dept.getDeptName())
|
||||
.eq(StrUtil.isNotBlank(dept.getStatus()), SysDept::getStatus, dept.getStatus())
|
||||
.apply(dataScope != null, dataScope != null ? dataScope.toString() : null)
|
||||
.orderByAsc(SysDept::getParentId)
|
||||
.orderByAsc(SysDept::getOrderNum));
|
||||
return baseMapper.selectDeptList(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
@@ -49,20 +48,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
@Override
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysRole> selectRoleList(SysRole role) {
|
||||
Map<String, Object> params = role.getParams();
|
||||
Object dataScope = params.get("dataScope");
|
||||
return list(new LambdaQueryWrapper<SysRole>()
|
||||
.like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName())
|
||||
.eq(StrUtil.isNotBlank(role.getStatus()), SysRole::getStatus, role.getStatus())
|
||||
.like(StrUtil.isNotBlank(role.getRoleKey()), SysRole::getRoleKey, role.getRoleKey())
|
||||
.apply(Validator.isNotEmpty(params.get("beginTime")),
|
||||
"date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')",
|
||||
params.get("beginTime"))
|
||||
.apply(Validator.isNotEmpty(params.get("endTime")),
|
||||
"date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')",
|
||||
params.get("endTime"))
|
||||
.apply(dataScope != null, dataScope != null ? dataScope.toString() : null)
|
||||
.orderByAsc(SysRole::getRoleSort));
|
||||
return baseMapper.selectRoleList(role);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +222,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleMenu(SysRole role) {
|
||||
int rows = 0;
|
||||
int rows = 1;
|
||||
// 新增用户与角色管理
|
||||
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
|
||||
for (Long menuId : role.getMenuIds()) {
|
||||
@@ -259,7 +245,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public int insertRoleDept(SysRole role) {
|
||||
int rows = 0;
|
||||
int rows = 1;
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
|
||||
for (Long deptId : role.getDeptIds()) {
|
||||
|
||||
Reference in New Issue
Block a user