一、该问题的重现步骤是什么?
按照文档上面的 5.4.2.1 纯注解配置数据权限,但是配置后无效
1)按文档要求在NoticeMapper中进行配置,如下图
我用create_dept作为权限字段,按照文档上面create_dept是默认字段,所以没有配置column
2)为了方便演示,我又根据文档调整了数据库中的数据
3)用postman访问,结果如下
显示的是5条数据,而不是3条
4)后台打印语句如下
2021-03-03 16:39:47.452 DEBUG 16444 --- [ XNIO-1 task-4] o.s.core.tenant.BladeTenantInterceptor : Original SQL: SELECT
n.*,
d.dict_value AS categoryName
FROM
blade_notice n
LEFT JOIN ( SELECT * FROM blade_dict WHERE CODE = 'notice' ) d ON n.category = d.dict_key
WHERE
n.is_deleted = 0 and n.tenant_id = ?
2021-03-03 16:39:47.455 DEBUG 16444 --- [ XNIO-1 task-4] o.s.core.tenant.BladeTenantInterceptor : parser sql: SELECT n.*, d.dict_value AS categoryName FROM blade_notice n LEFT JOIN (SELECT * FROM blade_dict WHERE CODE = 'notice') d ON n.category = d.dict_key WHERE n.is_deleted = 0 AND n.tenant_id = ?
2021-03-03 16:39:47.481 WARN 16444 --- [ XNIO-1 task-4] o.s.c.m.p.BladePaginationInterceptor : optimize this sql to a count sql has exception, sql:"SELECT n.*, d.dict_value AS categoryName FROM blade_notice n LEFT JOIN (SELECT * FROM blade_dict WHERE CODE = 'notice') d ON n.category = d.dict_key WHERE n.is_deleted = 0 AND n.tenant_id = ?", exception:
null
2021-03-03 16:39:47.483 DEBUG 16444 --- [ XNIO-1 task-4] o.s.d.m.N.selectNoticePage_mpCount : ==> Preparing: SELECT COUNT(1) FROM (SELECT n.*, d.dict_value AS categoryName FROM blade_notice n LEFT JOIN (SELECT * FROM blade_dict WHERE CODE = 'notice') d ON n.category = d.dict_key WHERE n.is_deleted = 0 AND n.tenant_id = ?) TOTAL
2021-03-03 16:39:47.486 DEBUG 16444 --- [ XNIO-1 task-4] o.s.d.m.N.selectNoticePage_mpCount : ==> Parameters: 000000(String)
2021-03-03 16:39:47.488 DEBUG 16444 --- [ XNIO-1 task-4] o.s.d.m.N.selectNoticePage_mpCount : <== Total: 1
2021-03-03 16:39:47.491 DEBUG 16444 --- [ XNIO-1 task-4] o.s.d.m.NoticeMapper.selectNoticePage : ==> Preparing: SELECT n.*, d.dict_value AS categoryName FROM blade_notice n LEFT JOIN (SELECT * FROM blade_dict WHERE CODE = 'notice') d ON n.category = d.dict_key WHERE n.is_deleted = 0 AND n.tenant_id = ? LIMIT ?
============== Sql Start ==============
Execute ID :org.springblade.desk.mapper.NoticeMapper.selectNoticePage_mpCount
Execute SQL :SELECT COUNT(1) FROM (SELECT n.*, d.dict_value AS categoryName FROM blade_notice n LEFT JOIN (SELECT * FROM blade_dict WHERE CODE = 'notice') d ON n.category = d.dict_key WHERE n.is_deleted = 0 AND n.tenant_id = ?) TOTAL
Execute Time:0 ms
============== Sql End ==============
2021-03-03 16:39:47.525 DEBUG 16444 --- [ XNIO-1 task-4] o.s.d.m.NoticeMapper.selectNoticePage : ==> Parameters: 000000(String), 10(Long)
============== Sql Start ==============
Execute ID :org.springblade.desk.mapper.NoticeMapper.selectNoticePage
Execute SQL :SELECT n.*, d.dict_value AS categoryName FROM blade_notice n LEFT JOIN (SELECT * FROM blade_dict WHERE CODE = 'notice') d ON n.category = d.dict_key WHERE n.is_deleted = 0 AND n.tenant_id = ? LIMIT ?
Execute Time:4 ms
============== Sql End ==============
2021-03-03 16:39:47.541 DEBUG 16444 --- [ XNIO-1 task-4] o.s.d.m.NoticeMapper.selectNoticePage : <== Total: 5
2021-03-03 16:39:47.543 INFO 16444 --- [ XNIO-1 task-4] o.s.core.log.aspect.RequestLogAspect :
整个sql语句里面,没有出现create_dept 这个字段,也没有出现如文档上面的 create_dept IN 这段sql
二、你期待的结果是什么?实际看到的又是什么?
期待看到纯注解配置数据权限生效,实际没有生效
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
我正在使用bladex2.7.0.RELEASE, 使用的操作系统为windows server2012
扫一扫访问 Blade技术社区 移动端