parent
c4cfaab621
commit
51b19fcff4
@ -0,0 +1,18 @@
|
||||
package com.ruoyi.common.core.service;
|
||||
|
||||
/**
|
||||
* 脱敏服务
|
||||
* 默认管理员不过滤
|
||||
* 需自行根据业务重写实现
|
||||
*
|
||||
* @author Lion Li
|
||||
* @version 3.6.0
|
||||
*/
|
||||
public interface SensitiveService {
|
||||
|
||||
/**
|
||||
* 是否脱敏
|
||||
*/
|
||||
boolean isSensitive();
|
||||
|
||||
}
|
||||
@ -1,35 +0,0 @@
|
||||
package com.ruoyi.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.ruoyi.common.annotation.Sensitive;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.enums.SensitiveStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 测试单表对象 test_demo
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2021-07-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class TestSensitive extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/** 身份证 */
|
||||
@Sensitive(strategy = SensitiveStrategy.ID_CARD)
|
||||
private String idCard;
|
||||
|
||||
/** 电话 */
|
||||
@Sensitive(strategy = SensitiveStrategy.PHONE)
|
||||
private String phone;
|
||||
|
||||
/** 地址 */
|
||||
@Sensitive(strategy = SensitiveStrategy.ADDRESS)
|
||||
private String address;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.SensitiveService;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 脱敏服务
|
||||
* 默认管理员不过滤
|
||||
* 需自行根据业务重写实现
|
||||
*
|
||||
* @author Lion Li
|
||||
* @version 3.6.0
|
||||
*/
|
||||
@Service
|
||||
public class SysSensitiveServiceImpl implements SensitiveService {
|
||||
|
||||
/**
|
||||
* 是否脱敏
|
||||
*/
|
||||
@Override
|
||||
public boolean isSensitive() {
|
||||
return SecurityUtils.isAdmin(SecurityUtils.getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue