mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
fix 修复数据权限问题
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,20 +49,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,28 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDeptVo">
|
||||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
|
||||
from sys_dept d
|
||||
</sql>
|
||||
|
||||
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where d.del_flag = '0'
|
||||
<if test="parentId != null and parentId != 0">
|
||||
AND parent_id = #{parentId}
|
||||
</if>
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND dept_name like concat('%', #{deptName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptListByRoleId" resultType="Integer">
|
||||
select d.dept_id
|
||||
from sys_dept d
|
||||
|
@ -39,6 +39,29 @@
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.del_flag = '0'
|
||||
<if test="roleName != null and roleName != ''">
|
||||
AND r.role_name like concat('%', #{roleName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
<if test="roleKey != null and roleKey != ''">
|
||||
AND r.role_key like concat('%', #{roleKey}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and ur.user_id = #{userId}
|
||||
|
Reference in New Issue
Block a user