Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
customer-service
Commits
35898aca
Commit
35898aca
authored
Mar 18, 2020
by
王向伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
身份证和手机号脱敏
parent
3da122d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
8 deletions
+86
-8
UserServiceImpl.java
.../cn/quantgroup/customer/service/impl/UserServiceImpl.java
+5
-8
DesensitizeUtil.java
...ain/java/cn/quantgroup/customer/util/DesensitizeUtil.java
+81
-0
No files found.
src/main/java/cn/quantgroup/customer/service/impl/UserServiceImpl.java
View file @
35898aca
...
...
@@ -22,10 +22,7 @@ import cn.quantgroup.customer.service.IKaService;
import
cn.quantgroup.customer.service.IUserService
;
import
cn.quantgroup.customer.service.IXyqbService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
import
cn.quantgroup.customer.util.DateUtil
;
import
cn.quantgroup.customer.util.IdcardUtils
;
import
cn.quantgroup.customer.util.JSONTools
;
import
cn.quantgroup.customer.util.ValidationUtil
;
import
cn.quantgroup.customer.util.*
;
import
cn.quantgroup.riskcontrol.model.AuthenticationUserDetail
;
import
cn.quantgroup.user.retbean.XUser
;
import
cn.quantgroup.user.retbean.XUserDetail
;
...
...
@@ -234,9 +231,9 @@ public class UserServiceImpl implements IUserService {
String
createdAt
=
DateUtil
.
format
(
userDetail
.
getCreatedAt
(),
DateUtil
.
DATE_FORMAT_1
);
userBasicInfo
.
setCreatedAt
(
createdAt
);
userBasicInfo
.
setGender
(
userDetail
.
getGender
().
getName
());
userBasicInfo
.
setIdNo
(
userDetail
.
getIdNo
(
));
userBasicInfo
.
setIdNo
(
DesensitizeUtil
.
idNoMark
(
userDetail
.
getIdNo
()
));
userBasicInfo
.
setName
(
userDetail
.
getName
());
userBasicInfo
.
setPhoneNo
(
userDetail
.
getPhoneNo
(
));
userBasicInfo
.
setPhoneNo
(
DesensitizeUtil
.
phoneMark
(
userDetail
.
getPhoneNo
()
));
userBasicInfo
.
setUserId
(
userDetail
.
getUserId
());
UserSysResult
<
XUser
>
userByUserId
=
userSdk
.
getService
().
findUserByUserId
(
userDetail
.
getUserId
());
if
(
userByUserId
!=
null
&&
userByUserId
.
isSuccess
())
{
...
...
@@ -260,9 +257,9 @@ public class UserServiceImpl implements IUserService {
String
createAt
=
DateUtil
.
format
(
userDetail
.
getCreatedAt
(),
DateUtil
.
DATE_FORMAT_1
);
userBasicInfo
.
setCreatedAt
(
createAt
);
userBasicInfo
.
setGender
(
userDetail
.
getGender
().
getName
());
userBasicInfo
.
setIdNo
(
userDetail
.
getIdNo
(
));
userBasicInfo
.
setIdNo
(
DesensitizeUtil
.
idNoMark
(
userDetail
.
getIdNo
()
));
userBasicInfo
.
setName
(
userDetail
.
getName
());
userBasicInfo
.
setPhoneNo
(
userDetail
.
getPhoneNo
(
));
userBasicInfo
.
setPhoneNo
(
DesensitizeUtil
.
phoneMark
(
userDetail
.
getPhoneNo
()
));
userBasicInfo
.
setUserId
(
userDetail
.
getUserId
());
UserSysResult
<
XUser
>
userByUserId
=
userSdk
.
getService
().
findUserByUserId
(
userDetail
.
getUserId
());
...
...
src/main/java/cn/quantgroup/customer/util/DesensitizeUtil.java
0 → 100644
View file @
35898aca
package
cn
.
quantgroup
.
customer
.
util
;
import
org.apache.commons.lang3.StringUtils
;
/**
* 脱敏工具类
*
* @author Wang Xiangwei
* @version 2020/3/18
*/
public
class
DesensitizeUtil
{
/**
* 保留前面几位
*
* @param str
* @param index
* @return
*/
public
static
String
left
(
String
str
,
int
index
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
return
""
;
}
String
name
=
StringUtils
.
left
(
str
,
index
);
return
StringUtils
.
rightPad
(
name
,
StringUtils
.
length
(
str
),
"*"
);
}
/**
* 前面保留 index 位明文,后面保留 end 位明文,如:[身份证号] 110****58,前面保留3位明文,后面保留2位明文
*
* @param str
* @param index
* @param end
* @return
*/
public
static
String
around
(
String
str
,
int
index
,
int
end
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
return
""
;
}
return
StringUtils
.
left
(
str
,
index
).
concat
(
StringUtils
.
removeStart
(
StringUtils
.
leftPad
(
StringUtils
.
right
(
str
,
end
),
StringUtils
.
length
(
str
),
"*"
),
"***"
));
}
/**
* 保留后面几位 如手机号 *******5678
*
* @param str
* @param end
* @return
*/
public
static
String
right
(
String
str
,
int
end
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
return
""
;
}
return
StringUtils
.
leftPad
(
StringUtils
.
right
(
str
,
end
),
StringUtils
.
length
(
str
),
"*"
);
}
public
static
String
phoneMark
(
String
phoneNo
)
{
if
(
StringUtils
.
isNotBlank
(
phoneNo
))
{
String
start
=
StringUtils
.
substring
(
phoneNo
,
0
,
3
);
String
end
=
StringUtils
.
substring
(
phoneNo
,
phoneNo
.
length
()
-
4
,
phoneNo
.
length
());
return
start
.
concat
(
"****"
).
concat
(
end
);
}
return
""
;
}
public
static
String
idNoMark
(
String
idNo
){
if
(
StringUtils
.
isBlank
(
idNo
)){
return
""
;
}
if
(
idNo
.
length
()
==
18
){
return
around
(
idNo
,
6
,
4
);
}
if
(
idNo
.
length
()
==
15
){
return
around
(
idNo
,
6
,
3
);
}
return
right
(
idNo
,
4
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment