什么情况下系统会查询blade_scope_data和blade_role_scope?

Blade 未结 2 2710

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

1. 自定义的sql在执行过程中报错:

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: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1

2. 

3.


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



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

spring-boot版本


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

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: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1


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


为什么其他自定义的sql在执行时没有抛出这个异常?唯独某个自定义下报异常了??

2条回答
  • 看错误是没有获取到token内的role_id,如果没有token,数据权限拦截自然就失效了

    where scope_category = 1 and role_id in ()


    具体逻辑可以看这个类

    image.png

    如果满足mapperSkip的条件,就会放行,不进行数据权限拦截

    image.png

    配置blade.data-scope.mapper-exclude属性来进行放行就行了

    image.png

    0 讨论(1)
  • 2021-08-13 17:15

    Blade-Boot使用多数据源,也碰到这个问题了!请问怎么解决

    0 讨论(2)
提交回复