数据权限的一点疑惑

Blade 未结 1 1317
红烧肉
红烧肉 剑者 2020-04-10 09:50

一、该问题的重现步骤是什么?

1. 您好,我在使用2.4的时候,数据权限那块即使我们用不到,库里也必须要加上data_scope和role_scope这两张表吗?不加的话查询的时候总是报错。

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?

我希望在我们项目中没有启用数据权限,能够不加相关的表,这样容易造成运维的疑惑和后续维护成本。


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

我们公司购买的企业版,linux系统上


四、请提供详细的错误堆栈信息,这很重要。

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select resource_code, scope_column, scope_field, scope_type, scope_value from blade_scope_data where scope_class = ? and id in (select scope_id from blade_role_scope where scope_category = 1 and role_id in (?))]; nested exception is java.sql.SQLSyntaxErrorException: Table 'lxsy_traceability.blade_scope_data' doesn't exist

### The error may exist in com/lxsy/modules/traceabilitychain/mapper/TraceabilityChainMapper.java (best guess)

### The error may involve com.lxsy.modules.traceabilitychain.mapper.TraceabilityChainMapper.selectPage

### The error occurred while executing a query


五、若有更多详细信息,请在下面提供。

我们不使用数据权限,可是在进行数据查询的时候总是报这个错误信息。加上那两张表就好了。


1条回答
  • 下版本会加上数据权限全局开关。目前需要这两张表

    作者追问:2020-04-10 14:02

    作者,你好,我看在tool项目中有个starter-datascope模块,mybatis拦截器里看到了您的处理逻辑,里边有个配置类

    DataScopeProperties

    List mapperKey = Arrays.asList("page", "Page", "list", "List");

    这里默认的数据权限过滤规则中,凡是包含这些关键字的都会进行数据权限的校验,现在是不是只有符合这个规则的methodName才会进行数据权限过滤?我可以重写这个类重新制定过滤规则吗?

    回答: 2020-04-11 13:17

    没问题,可以重写的。另外全局开启配置已经推送到dev分支了

    1 讨论(0)
提交回复