mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-04 01:52:21 +08:00
refactor(DataPermission.java): 数据权限注解重命名
This commit is contained in:
parent
4991ea573f
commit
7edac309ab
@ -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<SysDept> {
|
||||
|
||||
@InterceptorIgnore
|
||||
@DataPermission
|
||||
@Override
|
||||
List<SysDept> selectList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
|
||||
}
|
||||
|
@ -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<SysUser> {
|
||||
* @param queryParam
|
||||
* @return
|
||||
*/
|
||||
@InterceptorIgnore(deptAlias = "d")
|
||||
@DataPermission(deptAlias = "d")
|
||||
List<UserPageVO> listUsersWithPage(Page<UserPageVO> pageParam, UserPageQuery queryParam);
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.youlai.common.mybatis.handler;
|
||||
package com.youlai.common.mybatis.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 是否需要数据权限
|
||||
* 数据权限注解
|
||||
*
|
||||
* @author <a href="mailto:2256222053@qq.com">zc</a>
|
||||
* @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}
|
||||
* <p>
|
||||
* 默认打开,需要注解关闭
|
||||
*/
|
||||
|
||||
String deptAlias() default "";
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
package com.youlai.common.mybatis.generator;
|
||||
|
||||
/**
|
||||
* MP自定义主键生成器
|
||||
*
|
||||
* @author <a href="mailto:xianrui0365@163.com">haoxr</a>
|
||||
* @date 2021/11/1 23:53
|
||||
*/
|
||||
public class CustomKeyGenerator {
|
||||
}
|
@ -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<String> roles = JwtUtils.getRoles();
|
||||
|
Loading…
Reference in New Issue
Block a user