| | |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.apache.ibatis.reflection.SystemMetaObject; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | |
| | | @Slf4j |
| | | @ConditionalOnProperty(value = "domain.sensitive", havingValue = "true") |
| | | @Component |
| | | @Order(120) |
| | | public class SensitiveInterceptor implements Interceptor { |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | |
| | | // 获取对应的脱敏策略 并进行脱敏 |
| | | SensitiveStrategy type = annotation.strategy(); |
| | | Object o = type.getDesensitizer().apply((String) value); |
| | | log.debug("脱敏信息:{}->{}" , value, o.toString() ); |
| | | // 把脱敏后的值塞回去 |
| | | metaObject.setValue(name, o); |
| | | } |