diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysDeptMapper.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysDeptMapper.java index 9ac12c2eb..6d23b86ba 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysDeptMapper.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysDeptMapper.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.youlai.admin.pojo.entity.SysDept; -import com.youlai.common.mybatis.handler.InterceptorIgnore; +import com.youlai.common.mybatis.annotation.DataPermission; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -14,7 +14,7 @@ import java.util.List; @Mapper public interface SysDeptMapper extends BaseMapper { - @InterceptorIgnore + @DataPermission @Override List selectList(@Param(Constants.WRAPPER) Wrapper queryWrapper); } diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java index d749c4b12..7309c8082 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/mapper/SysUserMapper.java @@ -7,7 +7,7 @@ import com.youlai.admin.pojo.entity.SysUser; import com.youlai.admin.pojo.query.UserPageQuery; import com.youlai.admin.pojo.vo.user.UserFormVO; import com.youlai.admin.pojo.vo.user.UserPageVO; -import com.youlai.common.mybatis.handler.InterceptorIgnore; +import com.youlai.common.mybatis.annotation.DataPermission; import org.apache.ibatis.annotations.Mapper; import java.util.List; @@ -28,7 +28,7 @@ public interface SysUserMapper extends BaseMapper { * @param queryParam * @return */ - @InterceptorIgnore(deptAlias = "d") + @DataPermission(deptAlias = "d") List listUsersWithPage(Page pageParam, UserPageQuery queryParam); /** diff --git a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/annotation/DataPermission.java similarity index 69% rename from youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java rename to youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/annotation/DataPermission.java index 64eabeac9..7b6146322 100644 --- a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/InterceptorIgnore.java +++ b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/annotation/DataPermission.java @@ -1,9 +1,9 @@ -package com.youlai.common.mybatis.handler; +package com.youlai.common.mybatis.annotation; import java.lang.annotation.*; /** - * 是否需要数据权限 + * 数据权限注解 * * @author zc * @Date 2021-12-10 15:48 @@ -11,14 +11,11 @@ import java.lang.annotation.*; @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) -public @interface InterceptorIgnore { +public @interface DataPermission { /** * 数据权限 {@link com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor} - *

- * 默认打开,需要注解关闭 */ - String deptAlias() default ""; } diff --git a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/generator/CustomKeyGenerator.java b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/generator/CustomKeyGenerator.java deleted file mode 100644 index 10da7676c..000000000 --- a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/generator/CustomKeyGenerator.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.youlai.common.mybatis.generator; - -/** - * MP自定义主键生成器 - * - * @author haoxr - * @date 2021/11/1 23:53 - */ -public class CustomKeyGenerator { -} diff --git a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java index c4a35432f..070089947 100644 --- a/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java +++ b/youlai-common/common-mybatis/src/main/java/com/youlai/common/mybatis/handler/DataPermissionHandlerImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler; import com.youlai.common.constant.GlobalConstants; +import com.youlai.common.mybatis.annotation.DataPermission; import com.youlai.common.web.util.JwtUtils; import lombok.extern.slf4j.Slf4j; import net.sf.jsqlparser.expression.*; @@ -34,7 +35,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { clazz.getAnnotatedSuperclass(); Method[] methods = clazz.getDeclaredMethods(); for (Method method : methods) { - InterceptorIgnore annotation = method.getAnnotation(InterceptorIgnore.class); + DataPermission annotation = method.getAnnotation(DataPermission.class); if (ObjectUtils.isNotEmpty(annotation) && (method.getName().equals(methodName) || (method.getName() + "_COUNT").equals(methodName))) { // 获取当前的用户角色 List roles = JwtUtils.getRoles();