640 Star 3K Fork 1.2K

最后 / zuihou-admin-cloud

数据权限处理BUG

Closed
zhonglh  Opened this issue

在用户分页查询中发现, 在查询总数时没有加入 数据权限的处理逻辑, 而在查询具体数据时加上数据权限的逻辑, 导致总记录数和实际的数据不匹配。 查询出的SQL 如下:

Consume Time:1 ms 2020-02-10 00:47:23
Execute SQL:SELECT COUNT(1) FROM c_auth_user s

Consume Time:1 ms 2020-02-10 00:47:23
Execute SQL:select r.id, r.name, r.code, r.describe_, r.status, r.readonly, r.ds_type from c_auth_role r INNER JOIN c_auth_user_role ur on r.id = ur.role_id where status = true and ur.user_id = 0

Consume Time:1 ms 2020-02-10 00:47:23
Execute SQL:select * from (SELECT id, create_user, create_time, update_user, update_time, account, name, org_id, station_id, email, mobile, sex, status, avatar, work_describe, password_error_last_time, password_error_num, password_expire_time, password, last_login_time FROM c_auth_user s ORDER BY id DESC LIMIT 0,10) temp_data_scope where temp_data_scope.create_user = 0

1219829 zuihou111 1578946597 total 2 participants

Comments (2)

1219829 zuihou111 1578946597
最后 2020-02-12 17:26 owner

DataScopeInterceptor 设置序号为 @Order(10)
PaginationInterceptor 设置序号为 @Order(5)
让DataScopeInterceptor先于PaginationInterceptor执行。

修改后,打印的sql如下:

 Consume Time:3 ms 2020-02-12 17:22:43
 Execute SQL:SELECT r.id, r.name, r.code, r.describe_, r.status , r.readonly, r.ds_type FROM zuihou_base_0000.c_auth_role r INNER JOIN zuihou_base_0000.c_auth_user_role ur ON r.id = ur.role_id WHERE status = true AND ur.user_id = 3

 Consume Time:2 ms 2020-02-12 17:22:43
 Execute SQL:SELECT id, account, name, org_id AS org, station_id AS station , email, mobile, sex, status, avatar , nation, education, position_status, work_describe, password_error_last_time , password_error_num, password_expire_time, password, last_login_time, update_time , update_user, create_time, create_user FROM zuihou_base_0000.c_auth_user WHERE id = 3

 Consume Time:1 ms 2020-02-12 17:22:43
 Execute SQL:SELECT COUNT(1) FROM (SELECT id, create_user, create_time, update_user, update_time, account, name, org_id, station_id, email, mobile, sex, status, avatar, nation, education, position_status, work_describe, password_error_last_time, password_error_num, password_expire_time, password, last_login_time FROM zuihou_base_0000.c_auth_user s ORDER BY id DESC) temp_data_scope WHERE temp_data_scope.org_id IN (100)

 Consume Time:1 ms 2020-02-12 17:22:43
 Execute SQL:SELECT * FROM ( SELECT id, create_user, create_time, update_user, update_time , account, name, org_id, station_id, email , mobile, sex, status, avatar, nation , education, position_status, work_describe, password_error_last_time, password_error_num , password_expire_time, password, last_login_time FROM zuihou_base_0000.c_auth_user s ORDER BY id DESC ) temp_data_scope WHERE temp_data_scope.org_id IN (100) LIMIT 0,20

zhonglh 2020-02-14 17:23

厉害 :+1:

Sign in to comment

Assignees
Labels
bug
Projects
Milestones
Branches
Planed to start
Not set
Planed to end
Not set
Top level
Priority
Java
1
https://gitee.com/zuihou111/zuihou-admin-cloud.git
git@gitee.com:zuihou111/zuihou-admin-cloud.git
zuihou111
zuihou-admin-cloud
zuihou-admin-cloud

Search