mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
update 优化 脱敏增加角色及权限校验
This commit is contained in:
parent
bb6f79913b
commit
8a00416c40
@ -2,7 +2,6 @@ package org.dromara.common.sensitive.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.dromara.common.core.constant.UserConstants;
|
||||
import org.dromara.common.sensitive.core.SensitiveStrategy;
|
||||
import org.dromara.common.sensitive.handler.SensitiveHandler;
|
||||
|
||||
|
||||
@ -62,13 +62,13 @@ public class TestSensitiveController extends BaseController {
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Sensitive(strategy = SensitiveStrategy.EMAIL)
|
||||
@Sensitive(strategy = SensitiveStrategy.EMAIL, roleKey = "common", perms = "system:user:query1")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 银行卡
|
||||
*/
|
||||
@Sensitive(strategy = SensitiveStrategy.BANK_CARD)
|
||||
@Sensitive(strategy = SensitiveStrategy.BANK_CARD, roleKey = "common1", perms = "system:user:query")
|
||||
private String bankCard;
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
package org.dromara.system.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.sensitive.core.SensitiveService;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
@ -27,9 +26,21 @@ public class SysSensitiveServiceImpl implements SensitiveService {
|
||||
if (!StpUtil.isLogin()){
|
||||
return true;
|
||||
}
|
||||
if (StpUtil.hasRole(roleKey) || StpUtil.hasPermission(perms)){
|
||||
return false;
|
||||
|
||||
if (StringUtils.isNotEmpty(roleKey) && StringUtils.isNotEmpty(perms)){
|
||||
if (StpUtil.hasRole(roleKey) && StpUtil.hasPermission(perms)){
|
||||
return false;
|
||||
}
|
||||
}else if (StringUtils.isNotEmpty(roleKey)){
|
||||
if (StpUtil.hasRole(roleKey)){
|
||||
return false;
|
||||
}
|
||||
}else if (StringUtils.isNotEmpty(perms)){
|
||||
if (StpUtil.hasPermission(perms)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (TenantHelper.isEnable()) {
|
||||
return !LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user