From 7b3fca28447d2947136048b5d5052462ffb44d96 Mon Sep 17 00:00:00 2001
From: gaibu <1016771049@qq.com>
Date: Tue, 17 Jan 2023 10:52:37 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E8=84=B1=E6=95=8F=E7=BB=84=E4=BB=B6?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yudao-dependencies/pom.xml | 2 +-
yudao-framework/pom.xml | 2 +-
.../AbstractRegexDesensitizationHandler.java | 27 ----------
.../handler/BankCardDesensitization.java | 11 ----
.../handler/CarLicenseDesensitization.java | 10 ----
.../handler/ChineseNameDesensitization.java | 10 ----
.../DefaultDesensitizationHandler.java | 14 -----
.../handler/FixedPhoneDesensitization.java | 10 ----
.../slider/handler/IdCardDesensitization.java | 10 ----
.../handler/PasswordDesensitization.java | 10 ----
.../handler/PhoneNumberDesensitization.java | 11 ----
.../pom.xml | 12 +----
.../base/DesensitizationHandlerFactory.java} | 15 ++----
.../core/base/annotation/DesensitizeBy.java} | 17 +++----
.../base/handler/DesensitizationHandler.java | 6 +--
.../StringDesensitizeSerializer.java | 51 ++++++++++---------
.../regex/annotation/EmailDesensitize.java | 9 ++--
.../regex/annotation/RegexDesensitize.java | 7 ++-
.../AbstractRegexDesensitizationHandler.java | 37 ++++++++++++++
.../DefaultRegexDesensitizationHandler.java | 14 +++--
.../handler/EmailDesensitizationHandler.java | 14 ++++-
.../core/slider/annotation/BankCard.java | 6 ++-
.../core/slider/annotation/CarLicense.java | 6 ++-
.../core/slider/annotation/ChineseName.java | 6 ++-
.../core/slider/annotation/FixedPhone.java | 6 ++-
.../core/slider/annotation/IdCard.java | 6 ++-
.../core/slider/annotation/Password.java | 6 ++-
.../core/slider/annotation/PhoneNumber.java | 6 ++-
.../core/slider/annotation/Slider.java | 6 ++-
.../AbstractDesensitizationHandler.java | 49 +++++++++++++-----
.../handler/BankCardDesensitization.java | 27 ++++++++++
.../handler/CarLicenseDesensitization.java | 25 +++++++++
.../handler/ChineseNameDesensitization.java | 25 +++++++++
.../DefaultDesensitizationHandler.java | 25 +++++++++
.../handler/FixedPhoneDesensitization.java | 25 +++++++++
.../slider/handler/IdCardDesensitization.java | 25 +++++++++
.../handler/PasswordDesensitization.java | 25 +++++++++
.../handler/PhoneNumberDesensitization.java | 26 ++++++++++
38 files changed, 390 insertions(+), 209 deletions(-)
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java
delete mode 100644 yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/pom.xml (70%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerHolder.java => yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerFactory.java} (60%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/Desensitize.java => yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/DesensitizeBy.java} (50%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java (62%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize => yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base}/serializer/StringDesensitizeSerializer.java (71%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java (85%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java (90%)
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java (54%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java (52%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java (90%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java (90%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java (90%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java (90%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java (91%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java (90%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java (90%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java (91%)
rename yudao-framework/{yudao-spring-boot-starter-biz-desensitize => yudao-spring-boot-starter-desensitize}/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java (53%)
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java
create mode 100644 yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java
diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml
index be2f14dd6..f57f7a944 100644
--- a/yudao-dependencies/pom.xml
+++ b/yudao-dependencies/pom.xml
@@ -143,7 +143,7 @@
cn.iocoder.boot
- yudao-spring-boot-starter-biz-desensitize
+ yudao-spring-boot-starter-desensitize
${revision}
diff --git a/yudao-framework/pom.xml b/yudao-framework/pom.xml
index 0f20b1a78..12244f5ce 100644
--- a/yudao-framework/pom.xml
+++ b/yudao-framework/pom.xml
@@ -41,7 +41,7 @@
yudao-spring-boot-starter-flowable
yudao-spring-boot-starter-captcha
yudao-spring-boot-starter-websocket
- yudao-spring-boot-starter-biz-desensitize
+ yudao-spring-boot-starter-desensitize
yudao-framework
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java
deleted file mode 100644
index a9d495adf..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.regex.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler;
-
-import java.lang.annotation.Annotation;
-
-public abstract class AbstractRegexDesensitizationHandler implements DesensitizationHandler {
-
- @Override
- public String desensitize(String origin, T anno) {
- Object[] args = getArgs(anno);
- String regex = (String) args[0];
- String replacer = (String) args[1];
-
- return origin.replaceAll(regex, replacer);
- }
-
- // TODO @城:是不是抽象两个方法,一个拿 regex;一个拿 replacer
-
- /**
- * 获取注解的参数
- *
- * @param anno 注解信息
- * @return 注解的参数
- */
- abstract Object[] getArgs(T anno);
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java
deleted file mode 100644
index 942ca258f..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.BankCard;
-
-public class BankCardDesensitization extends AbstractDesensitizationHandler {
-
- @Override
- Object[] getArgs(BankCard anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
\ No newline at end of file
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java
deleted file mode 100644
index d7cef7d2f..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.CarLicense;
-
-public class CarLicenseDesensitization extends AbstractDesensitizationHandler {
- @Override
- Object[] getArgs(CarLicense anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java
deleted file mode 100644
index ba0a6607b..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.ChineseName;
-
-public class ChineseNameDesensitization extends AbstractDesensitizationHandler {
- @Override
- Object[] getArgs(ChineseName anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java
deleted file mode 100644
index 3be33a0b8..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.Slider;
-
-/**
- * 滑动脱敏处理器
- */
-public class DefaultDesensitizationHandler extends AbstractDesensitizationHandler {
-
- @Override
- Object[] getArgs(Slider anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java
deleted file mode 100644
index 8fb71289f..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.FixedPhone;
-
-public class FixedPhoneDesensitization extends AbstractDesensitizationHandler {
- @Override
- Object[] getArgs(FixedPhone anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java
deleted file mode 100644
index ce76b357e..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.IdCard;
-
-public class IdCardDesensitization extends AbstractDesensitizationHandler {
- @Override
- Object[] getArgs(IdCard anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java
deleted file mode 100644
index 35a656c3d..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.Password;
-
-public class PasswordDesensitization extends AbstractDesensitizationHandler {
- @Override
- Object[] getArgs(Password anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java b/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java
deleted file mode 100644
index 0525cb874..000000000
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
-
-import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.PhoneNumber;
-
-public class PhoneNumberDesensitization extends AbstractDesensitizationHandler {
-
- @Override
- Object[] getArgs(PhoneNumber anno) {
- return new Object[]{anno.prefixKeep(), anno.suffixKeep(), anno.replacer()};
- }
-}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/pom.xml b/yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml
similarity index 70%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/pom.xml
rename to yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml
index 1afb387b8..53879bd0f 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/pom.xml
@@ -9,16 +9,8 @@
${revision}
-
- yudao-spring-boot-starter-biz-desensitize
-
-
-
-
- 11
- 11
- UTF-8
-
+ yudao-spring-boot-starter-desensitize
+ 脱敏组件
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerHolder.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerFactory.java
similarity index 60%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerHolder.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerFactory.java
index 95c193f6b..abd756ef2 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerHolder.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/DesensitizationHandlerFactory.java
@@ -2,33 +2,28 @@ package cn.iocoder.yudao.framework.desensitize.core.base;
import cn.hutool.core.util.ReflectUtil;
import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler;
-import cn.iocoder.yudao.framework.desensitize.core.regex.handler.DefaultRegexDesensitizationHandler;
-import cn.iocoder.yudao.framework.desensitize.core.slider.handler.DefaultDesensitizationHandler;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-// TODO @城:DesensitizationHandlerHolder =》 DesensitizationHandlerFactory? Holder 没有太多工厂的味道哈
/**
* 脱敏处理器 Holder
+ *
+ * @author gaibu
*/
-public class DesensitizationHandlerHolder {
+public class DesensitizationHandlerFactory {
/**
* handler 缓存,默认初始化内置的处理器
*/
- private static final Map, DesensitizationHandler> HANDLER_MAP = new ConcurrentHashMap<>() {{
- // TODO @城:这 2 个,是不是不用呀?需要的时候初始化
- put(DefaultRegexDesensitizationHandler.class, new DefaultRegexDesensitizationHandler());
- put(DefaultDesensitizationHandler.class, new DefaultDesensitizationHandler());
- }};
+ private static final Map, DesensitizationHandler> HANDLER_MAP = new ConcurrentHashMap, DesensitizationHandler>();
public static DesensitizationHandler getDesensitizationHandler(Class extends DesensitizationHandler> clazz) {
DesensitizationHandler handler = HANDLER_MAP.get(clazz);
if (handler != null) {
return handler;
}
- synchronized (DesensitizationHandlerHolder.class) {
+ synchronized (DesensitizationHandlerFactory.class) {
handler = HANDLER_MAP.get(clazz);
// 双重校验锁
if (handler != null) {
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/Desensitize.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/DesensitizeBy.java
similarity index 50%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/Desensitize.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/DesensitizeBy.java
index b95ccd68d..d06e633a6 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/Desensitize.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/annotation/DesensitizeBy.java
@@ -1,7 +1,7 @@
package cn.iocoder.yudao.framework.desensitize.core.base.annotation;
import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler;
-import cn.iocoder.yudao.framework.desensitize.serializer.StringDesensitizeSerializer;
+import cn.iocoder.yudao.framework.desensitize.core.base.serializer.StringDesensitizeSerializer;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -11,21 +11,20 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-// TODO @城:每个接口上,author 写下哈。
-// TODO @城:Desensitize = 》DesensitizeBy
-// TODO @城:Desensitize 类注释,方便读者阅读理解
/**
- * Desensitize 顶级脱敏注解
+ * 顶级脱敏注解,自定义注解需要使用此注解。
+ *
+ * @author gaibu
*/
@Documented
@Target(ElementType.ANNOTATION_TYPE)
@Retention(RetentionPolicy.RUNTIME)
-@JacksonAnnotationsInside // TODO @城:这个的作用,也可以写下
-@JsonSerialize(using = StringDesensitizeSerializer.class) // TODO @城:这个的作用,也可以写下
-public @interface Desensitize {
+@JacksonAnnotationsInside // 此注解是其他所有 jackson 注解的元注解,打上了此注解的注解表明是 jackson 注解的一部分
+@JsonSerialize(using = StringDesensitizeSerializer.class) // 指定序列化器
+public @interface DesensitizeBy {
/**
* 脱敏处理器
*/
- Class extends DesensitizationHandler> desensitizationBy(); // TODO @城:desensitizationBy -> handler
+ Class extends DesensitizationHandler> handler();
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java
similarity index 62%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java
index a4dd24665..e59d96cec 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/handler/DesensitizationHandler.java
@@ -10,10 +10,10 @@ public interface DesensitizationHandler {
/**
* 脱敏
*
- * @param origin 原始字符串
- * @param anno 注解信息 // TODO 不要这样的缩写哈,anno -> annotation
+ * @param origin 原始字符串
+ * @param annotation 注解信息
* @return 脱敏后的字符串
*/
- String desensitize(String origin, T anno);
+ String desensitize(String origin, T annotation);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/serializer/StringDesensitizeSerializer.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/serializer/StringDesensitizeSerializer.java
similarity index 71%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/serializer/StringDesensitizeSerializer.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/serializer/StringDesensitizeSerializer.java
index accfa77dd..85dee2f53 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/serializer/StringDesensitizeSerializer.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/base/serializer/StringDesensitizeSerializer.java
@@ -1,12 +1,12 @@
-package cn.iocoder.yudao.framework.desensitize.serializer;
+package cn.iocoder.yudao.framework.desensitize.core.base.serializer;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler;
-import cn.iocoder.yudao.framework.desensitize.core.base.DesensitizationHandlerHolder;
+import cn.iocoder.yudao.framework.desensitize.core.base.DesensitizationHandlerFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -14,40 +14,36 @@ import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import lombok.Getter;
+import lombok.Setter;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-// TODO @城:挪到 base/serializer 包下
/**
* 脱敏序列化器
+ *
+ * @author gaibu
*/
public class StringDesensitizeSerializer extends StdSerializer implements ContextualSerializer {
+ @Getter
+ @Setter
private DesensitizationHandler desensitizationHandler;
protected StringDesensitizeSerializer() {
super(String.class);
}
- // TODO @城:get 和 set 方法是必须的么?如果是的话,可以换成 lombok 注解哈,简洁一点~
- public DesensitizationHandler getDesensitizationHandler() {
- return desensitizationHandler;
- }
-
- public void setDesensitizationHandler(DesensitizationHandler desensitizationHandler) {
- this.desensitizationHandler = desensitizationHandler;
- }
-
@Override
public JsonSerializer> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) throws JsonMappingException {
- Desensitize annotation = beanProperty.getAnnotation(Desensitize.class);
+ DesensitizeBy annotation = beanProperty.getAnnotation(DesensitizeBy.class);
if (annotation == null) {
return this;
}
StringDesensitizeSerializer serializer = new StringDesensitizeSerializer();
- serializer.setDesensitizationHandler(DesensitizationHandlerHolder.getDesensitizationHandler(annotation.desensitizationBy()));
+ serializer.setDesensitizationHandler(DesensitizationHandlerFactory.getDesensitizationHandler(annotation.handler()));
return serializer;
}
@@ -57,21 +53,17 @@ public class StringDesensitizeSerializer extends StdSerializer implement
gen.writeNull();
return;
}
-
- // TODO @城:抽个 private getField 方法。让这个方法的逻辑主干,更清晰
- String currentName = gen.getOutputContext().getCurrentName();
- Object currentValue = gen.getCurrentValue();
- Class> currentValueClass = currentValue.getClass();
- Field field = ReflectUtil.getField(currentValueClass, currentName);
+ // 获取序列化字段
+ Field field = getField(gen);
// 自定义处理器
- Desensitize[] annotations = AnnotationUtil.getCombinationAnnotations(field, Desensitize.class);
+ DesensitizeBy[] annotations = AnnotationUtil.getCombinationAnnotations(field, DesensitizeBy.class);
if (ArrayUtil.isEmpty(annotations)) {
gen.writeString(value);
return;
}
for (Annotation annotation : field.getAnnotations()) {
- if (AnnotationUtil.hasAnnotation(annotation.annotationType(), Desensitize.class)) {
+ if (AnnotationUtil.hasAnnotation(annotation.annotationType(), DesensitizeBy.class)) {
value = this.desensitizationHandler.desensitize(value, annotation);
gen.writeString(value);
return;
@@ -80,4 +72,17 @@ public class StringDesensitizeSerializer extends StdSerializer implement
gen.writeString(value);
}
+ /**
+ * 获取字段
+ *
+ * @param gen JsonGenerator
+ * @return 字段
+ */
+ private Field getField(JsonGenerator gen) {
+ String currentName = gen.getOutputContext().getCurrentName();
+ Object currentValue = gen.getCurrentValue();
+ Class> currentValueClass = currentValue.getClass();
+ return ReflectUtil.getField(currentValueClass, currentName);
+ }
+
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java
similarity index 85%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java
index ebd754b1e..303320b70 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/EmailDesensitize.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.regex.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.regex.handler.EmailDesensitizationHandler;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,17 +12,20 @@ import java.lang.annotation.Target;
/**
* 邮箱
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = EmailDesensitizationHandler.class)
+@DesensitizeBy(handler = EmailDesensitizationHandler.class)
public @interface EmailDesensitize {
+
/**
* 匹配的正则表达式
*/
- String regex() default "(^.)[^@]*(@.*$)";
+ String regex() default "(^.)[^@]*(@.*$)";
/**
* 替换规则,邮箱;比如:example@gmail.com脱敏之后为e****@gmail.com
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java
index 7ee6fadd5..6c457fd0c 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/annotation/RegexDesensitize.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.regex.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.regex.handler.DefaultRegexDesensitizationHandler;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,13 +12,16 @@ import java.lang.annotation.Target;
/**
* 正则脱敏注解
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = DefaultRegexDesensitizationHandler.class)
+@DesensitizeBy(handler = DefaultRegexDesensitizationHandler.class)
public @interface RegexDesensitize {
+
/**
* 匹配的正则表达式(默认匹配所有)
*/
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java
new file mode 100644
index 000000000..158c6de3d
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/AbstractRegexDesensitizationHandler.java
@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.framework.desensitize.core.regex.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationHandler;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * 正则表达式脱敏处理器抽象类,已实现通用的方法
+ *
+ * @author gaibu
+ */
+public abstract class AbstractRegexDesensitizationHandler implements DesensitizationHandler {
+
+ @Override
+ public String desensitize(String origin, T annotation) {
+ String regex = getRegex(annotation);
+ String replacer = getReplacer(annotation);
+
+ return origin.replaceAll(regex, replacer);
+ }
+
+ /**
+ * 获取注解上的 regex 参数
+ *
+ * @param annotation 注解信息
+ * @return 正则表达式
+ */
+ abstract String getRegex(T annotation);
+
+ /**
+ * 获取注解上的 replacer 参数
+ *
+ * @param annotation 注解信息
+ * @return 待替换的字符串
+ */
+ abstract String getReplacer(T annotation);
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java
similarity index 54%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java
index a21734909..b3a788aa9 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/DefaultRegexDesensitizationHandler.java
@@ -3,12 +3,20 @@ package cn.iocoder.yudao.framework.desensitize.core.regex.handler;
import cn.iocoder.yudao.framework.desensitize.core.regex.annotation.RegexDesensitize;
/**
- * 正则脱敏处理器
+ * 默认正则脱敏处理器
+ *
+ * @author gaibu
*/
public class DefaultRegexDesensitizationHandler extends AbstractRegexDesensitizationHandler {
+
@Override
- Object[] getArgs(RegexDesensitize anno) {
- return new Object[]{anno.regex(), anno.replacer()};
+ String getRegex(RegexDesensitize annotation) {
+ return annotation.regex();
+ }
+
+ @Override
+ String getReplacer(RegexDesensitize annotation) {
+ return annotation.replacer();
}
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java
similarity index 52%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java
index 9336351da..5313381c3 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/regex/handler/EmailDesensitizationHandler.java
@@ -2,10 +2,20 @@ package cn.iocoder.yudao.framework.desensitize.core.regex.handler;
import cn.iocoder.yudao.framework.desensitize.core.regex.annotation.EmailDesensitize;
+/**
+ * 邮箱脱敏处理器
+ *
+ * @author gaibu
+ */
public class EmailDesensitizationHandler extends AbstractRegexDesensitizationHandler {
@Override
- Object[] getArgs(EmailDesensitize anno) {
- return new Object[]{anno.regex(), anno.replacer()};
+ String getRegex(EmailDesensitize annotation) {
+ return annotation.regex();
+ }
+
+ @Override
+ String getReplacer(EmailDesensitize annotation) {
+ return annotation.replacer();
}
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java
index 4c41569e8..762ce3118 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/BankCard.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.BankCardDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 银行卡号
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = BankCardDesensitization.class)
+@DesensitizeBy(handler = BankCardDesensitization.class)
public @interface BankCard {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java
index fb89ddb08..d3d09ad42 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/CarLicense.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.CarLicenseDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 车牌号
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = CarLicenseDesensitization.class)
+@DesensitizeBy(handler = CarLicenseDesensitization.class)
public @interface CarLicense {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java
index 3b4a1a530..92e46e594 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/ChineseName.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.ChineseNameDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 中文名
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = ChineseNameDesensitization.class)
+@DesensitizeBy(handler = ChineseNameDesensitization.class)
public @interface ChineseName {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java
index 663388d89..867552164 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/FixedPhone.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.FixedPhoneDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 固定电话
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = FixedPhoneDesensitization.class)
+@DesensitizeBy(handler = FixedPhoneDesensitization.class)
public @interface FixedPhone {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java
similarity index 91%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java
index ac2ba9cd3..7b976bac6 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/IdCard.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.IdCardDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 身份证
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = IdCardDesensitization.class)
+@DesensitizeBy(handler = IdCardDesensitization.class)
public @interface IdCard {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java
index c4bb6e1eb..bbe067ab7 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Password.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.PasswordDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 密码
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = PasswordDesensitization.class)
+@DesensitizeBy(handler = PasswordDesensitization.class)
public @interface Password {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java
similarity index 90%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java
index c78354d15..87d7893fe 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/PhoneNumber.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.PhoneNumberDesensitization;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 手机号
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = PhoneNumberDesensitization.class)
+@DesensitizeBy(handler = PhoneNumberDesensitization.class)
public @interface PhoneNumber {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java
similarity index 91%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java
index c752df310..4d3cac7a3 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/annotation/Slider.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.desensitize.core.slider.annotation;
-import cn.iocoder.yudao.framework.desensitize.core.base.annotation.Desensitize;
+import cn.iocoder.yudao.framework.desensitize.core.base.annotation.DesensitizeBy;
import cn.iocoder.yudao.framework.desensitize.core.slider.handler.DefaultDesensitizationHandler;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
@@ -12,12 +12,14 @@ import java.lang.annotation.Target;
/**
* 滑动脱敏注解
+ *
+ * @author gaibu
*/
@Documented
@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
-@Desensitize(desensitizationBy = DefaultDesensitizationHandler.class)
+@DesensitizeBy(handler = DefaultDesensitizationHandler.class)
public @interface Slider {
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java
similarity index 53%
rename from yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java
rename to yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java
index 0b25cdbe5..bd5ca926d 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/AbstractDesensitizationHandler.java
@@ -4,14 +4,18 @@ import cn.iocoder.yudao.framework.desensitize.core.base.handler.DesensitizationH
import java.lang.annotation.Annotation;
+/**
+ * 滑动脱敏处理器抽象类,已实现通用的方法
+ *
+ * @author gaibu
+ */
public abstract class AbstractDesensitizationHandler implements DesensitizationHandler {
@Override
- public String desensitize(String origin, T anno) {
- Object[] args = getArgs(anno);
- int prefixKeep = (Integer) args[0];
- int suffixKeep = (Integer) args[1];
- String replacer = (String) args[2];
+ public String desensitize(String origin, T annotation) {
+ int prefixKeep = getPrefixKeep(annotation);
+ int suffixKeep = getSuffixKeep(annotation);
+ String replacer = getReplacer(annotation);
int length = origin.length();
// 情况一:原始字符串长度小于等于保留长度,则原始字符串全部替换
@@ -19,26 +23,41 @@ public abstract class AbstractDesensitizationHandler imple
return buildReplacerByLength(replacer, length);
}
- // 情况二:如果原始字符串小于等于前后缀保留字符串长度,则原始字符串全部替换
+ // 情况二:原始字符串长度小于等于前后缀保留字符串长度,则原始字符串全部替换
if ((prefixKeep + suffixKeep) >= length) {
return buildReplacerByLength(replacer, length);
}
- // 情况三:TODO 城
+ // 情况三:原始字符串长度大于前后缀保留字符串长度,则替换中间字符串
int interval = length - prefixKeep - suffixKeep;
return origin.substring(0, prefixKeep) +
buildReplacerByLength(replacer, interval) +
origin.substring(prefixKeep + interval);
}
- // TODO @城:类似,子类直接获取到参数哈
/**
- * 获取注解的参数
+ * 前缀保留长度
*
- * @param anno 注解信息
- * @return 注解的参数
+ * @param annotation 注解信息
+ * @return 前缀保留长度
*/
- abstract Object[] getArgs(T anno);
+ abstract Integer getPrefixKeep(T annotation);
+
+ /**
+ * 后缀保留长度
+ *
+ * @param annotation 注解信息
+ * @return 后缀保留长度
+ */
+ abstract Integer getSuffixKeep(T annotation);
+
+ /**
+ * 替换符
+ *
+ * @param annotation 注解信息
+ * @return 替换符
+ */
+ abstract String getReplacer(T annotation);
/**
* 根据长度循环构建替换符
@@ -48,7 +67,11 @@ public abstract class AbstractDesensitizationHandler imple
* @return 构建后的替换符
*/
private String buildReplacerByLength(String replacer, int length) {
- return String.valueOf(replacer).repeat(Math.max(0, length));
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < length; i++) {
+ builder.append(replacer);
+ }
+ return builder.toString();
}
}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java
new file mode 100644
index 000000000..76e63a6b1
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/BankCardDesensitization.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.BankCard;
+
+/**
+ * 银行卡脱敏处理器
+ *
+ * @author gaibu
+ */
+public class BankCardDesensitization extends AbstractDesensitizationHandler {
+
+ @Override
+ Integer getPrefixKeep(BankCard annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(BankCard annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(BankCard annotation) {
+ return annotation.replacer();
+ }
+
+}
\ No newline at end of file
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java
new file mode 100644
index 000000000..742851a31
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/CarLicenseDesensitization.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.CarLicense;
+
+/**
+ * 车牌号脱敏处理器
+ *
+ * @author gaibu
+ */
+public class CarLicenseDesensitization extends AbstractDesensitizationHandler {
+ @Override
+ Integer getPrefixKeep(CarLicense annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(CarLicense annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(CarLicense annotation) {
+ return annotation.replacer();
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java
new file mode 100644
index 000000000..f7314867d
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/ChineseNameDesensitization.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.ChineseName;
+
+/**
+ * 中文姓名脱敏处理器
+ *
+ * @author gaibu
+ */
+public class ChineseNameDesensitization extends AbstractDesensitizationHandler {
+ @Override
+ Integer getPrefixKeep(ChineseName annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(ChineseName annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(ChineseName annotation) {
+ return annotation.replacer();
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java
new file mode 100644
index 000000000..0c498b071
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/DefaultDesensitizationHandler.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.Slider;
+
+/**
+ * 滑动脱敏处理器
+ *
+ * @author gaibu
+ */
+public class DefaultDesensitizationHandler extends AbstractDesensitizationHandler {
+ @Override
+ Integer getPrefixKeep(Slider annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(Slider annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(Slider annotation) {
+ return annotation.replacer();
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java
new file mode 100644
index 000000000..50672ce35
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/FixedPhoneDesensitization.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.FixedPhone;
+
+/**
+ * 固定电话脱敏处理器
+ *
+ * @author gaibu
+ */
+public class FixedPhoneDesensitization extends AbstractDesensitizationHandler {
+ @Override
+ Integer getPrefixKeep(FixedPhone annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(FixedPhone annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(FixedPhone annotation) {
+ return annotation.replacer();
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java
new file mode 100644
index 000000000..657a19129
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/IdCardDesensitization.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.IdCard;
+
+/**
+ * 身份证脱敏处理器
+ *
+ * @author gaibu
+ */
+public class IdCardDesensitization extends AbstractDesensitizationHandler {
+ @Override
+ Integer getPrefixKeep(IdCard annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(IdCard annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(IdCard annotation) {
+ return annotation.replacer();
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java
new file mode 100644
index 000000000..d3561ce5d
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PasswordDesensitization.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.Password;
+
+/**
+ * 密码脱敏处理器
+ *
+ * @author gaibu
+ */
+public class PasswordDesensitization extends AbstractDesensitizationHandler {
+ @Override
+ Integer getPrefixKeep(Password annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(Password annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(Password annotation) {
+ return annotation.replacer();
+ }
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java
new file mode 100644
index 000000000..e6c11bd44
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-desensitize/src/main/java/cn/iocoder/yudao/framework/desensitize/core/slider/handler/PhoneNumberDesensitization.java
@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.framework.desensitize.core.slider.handler;
+
+import cn.iocoder.yudao.framework.desensitize.core.slider.annotation.PhoneNumber;
+
+/**
+ * 手机号脱敏处理器
+ *
+ * @author gaibu
+ */
+public class PhoneNumberDesensitization extends AbstractDesensitizationHandler {
+
+ @Override
+ Integer getPrefixKeep(PhoneNumber annotation) {
+ return annotation.prefixKeep();
+ }
+
+ @Override
+ Integer getSuffixKeep(PhoneNumber annotation) {
+ return annotation.suffixKeep();
+ }
+
+ @Override
+ String getReplacer(PhoneNumber annotation) {
+ return annotation.replacer();
+ }
+}