From 48bf574e2f36627f806da4d0f33c5c628a1b789c Mon Sep 17 00:00:00 2001 From: chuan <2256222053@qq.com> Date: Sat, 24 Sep 2022 20:02:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(youlai-admin):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E6=97=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=A7=92=E8=89=B2=E5=92=8C=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复开启数据权限时查询角色和部门过滤失败 --- .../youlai/admin/mapper/SysRoleMapper.java | 20 +++---- .../service/impl/SysRoleServiceImpl.java | 21 +------- .../main/resources/mapper/SysRoleMapper.xml | 53 +++++++++++++++++++ 3 files changed, 63 insertions(+), 31 deletions(-) create mode 100644 youlai-admin/admin-boot/src/main/resources/mapper/SysRoleMapper.xml diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysRoleMapper.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysRoleMapper.java index 0c9cabad2..0f25de038 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysRoleMapper.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysRoleMapper.java @@ -1,15 +1,10 @@ package com.youlai.admin.mapper; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Constants; -import com.youlai.admin.pojo.entity.SysDept; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.youlai.admin.pojo.entity.SysRole; -import com.youlai.admin.pojo.entity.SysUser; +import com.youlai.admin.pojo.query.RolePageQuery; import com.youlai.common.mybatis.annotation.DataPermission; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -18,11 +13,12 @@ import java.util.List; public interface SysRoleMapper extends BaseMapper { - @DataPermission() - @Override - List selectList(@Param(Constants.WRAPPER) Wrapper queryWrapper); - @DataPermission() - > E selectPage(E page, @Param("ew") Wrapper queryWrapper); + @DataPermission(deptAlias = "d",userAlias = "u") + Page listRolePages(Page page, RolePageQuery queryParams,boolean isRoot,String rootCode); + + + @DataPermission(deptAlias = "d",userAlias = "u") + List listDeptOptions(boolean isRoot,String rootCode); } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysRoleServiceImpl.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysRoleServiceImpl.java index ecf5c85a7..648c59ec3 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysRoleServiceImpl.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/SysRoleServiceImpl.java @@ -59,19 +59,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl // 查询参数 int pageNum = queryParams.getPageNum(); int pageSize = queryParams.getPageSize(); - String keywords = queryParams.getKeywords(); - - // 查询数据 - Page rolePage = this.page( - new Page<>(pageNum, pageSize), - new LambdaQueryWrapper() - .like(StrUtil.isNotBlank(keywords), SysRole::getName, keywords) - .or() - .like(StrUtil.isNotBlank(keywords), SysRole::getCode, keywords) - .ne(!UserUtils.isRoot(), SysRole::getCode, GlobalConstants.ROOT_ROLE_CODE) // 非超级管理员不显示超级管理员角色 - .select(SysRole::getId, SysRole::getName, SysRole::getCode,SysRole::getDataScope) - ); - + Page rolePage = this.baseMapper.listRolePages( new Page<>(pageNum, pageSize), queryParams,UserUtils.isRoot(),GlobalConstants.ROOT_ROLE_CODE); // 实体转换 Page pageResult = roleConverter.entity2Page(rolePage); return pageResult; @@ -85,12 +73,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl @Override public List