个人信息脱敏处理
This commit is contained in:
parent
c08fd22ec0
commit
35beb3d87d
@ -7,6 +7,7 @@ import cn.com.tenlion.systemhouse.pojo.dtos.houseuser.HouseUserDTO;
|
|||||||
import cn.com.tenlion.systemhouse.pojo.pos.houseuser.HouseUserPO;
|
import cn.com.tenlion.systemhouse.pojo.pos.houseuser.HouseUserPO;
|
||||||
import cn.com.tenlion.systemhouse.pojo.vos.houseuser.HouseUserVO;
|
import cn.com.tenlion.systemhouse.pojo.vos.houseuser.HouseUserVO;
|
||||||
import cn.com.tenlion.systemhouse.service.houseuser.IHouseUserService;
|
import cn.com.tenlion.systemhouse.service.houseuser.IHouseUserService;
|
||||||
|
import cn.com.tenlion.systemhouse.utils.datacover.DataCoverUtils;
|
||||||
import ink.wgink.common.base.DefaultBaseService;
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
import ink.wgink.pojo.ListPage;
|
import ink.wgink.pojo.ListPage;
|
||||||
import ink.wgink.pojo.result.SuccessResultList;
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
@ -144,7 +145,13 @@ public class HouseUserServiceImpl extends DefaultBaseService implements IHouseUs
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HouseUserDTO> list(Map<String, Object> params) {
|
public List<HouseUserDTO> list(Map<String, Object> params) {
|
||||||
return houseUserDao.list(params);
|
List<HouseUserDTO> list = houseUserDao.list(params);
|
||||||
|
for(HouseUserDTO houseUserDTO: list) {
|
||||||
|
houseUserDTO.setName(DataCoverUtils.desensitizeName(houseUserDTO.getName()));
|
||||||
|
houseUserDTO.setCardNum(DataCoverUtils.desensitizeIdCardNumber(houseUserDTO.getCardNum()));
|
||||||
|
houseUserDTO.setPhone(DataCoverUtils.desensitizePhoneNumber(houseUserDTO.getPhone()));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,7 @@ import cn.com.tenlion.systemhouse.pojo.dtos.houseusersub.HouseUserSubDTO;
|
|||||||
import cn.com.tenlion.systemhouse.pojo.pos.houseusersub.HouseUserSubPO;
|
import cn.com.tenlion.systemhouse.pojo.pos.houseusersub.HouseUserSubPO;
|
||||||
import cn.com.tenlion.systemhouse.pojo.vos.houseusersub.HouseUserSubVO;
|
import cn.com.tenlion.systemhouse.pojo.vos.houseusersub.HouseUserSubVO;
|
||||||
import cn.com.tenlion.systemhouse.service.houseusersub.IHouseUserSubService;
|
import cn.com.tenlion.systemhouse.service.houseusersub.IHouseUserSubService;
|
||||||
|
import cn.com.tenlion.systemhouse.utils.datacover.DataCoverUtils;
|
||||||
import ink.wgink.common.base.DefaultBaseService;
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
import ink.wgink.pojo.ListPage;
|
import ink.wgink.pojo.ListPage;
|
||||||
import ink.wgink.pojo.result.SuccessResultList;
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
@ -140,7 +141,13 @@ public class HouseUserSubServiceImpl extends DefaultBaseService implements IHous
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<HouseUserSubDTO> list(Map<String, Object> params) {
|
public List<HouseUserSubDTO> list(Map<String, Object> params) {
|
||||||
return houseUserSubDao.list(params);
|
List<HouseUserSubDTO> list = houseUserSubDao.list(params);
|
||||||
|
for (HouseUserSubDTO houseUserSubDTO : list) {
|
||||||
|
houseUserSubDTO.setName(DataCoverUtils.desensitizeName(houseUserSubDTO.getName()));
|
||||||
|
houseUserSubDTO.setCardNum(DataCoverUtils.desensitizeIdCardNumber(houseUserSubDTO.getCardNum()));
|
||||||
|
houseUserSubDTO.setPhone(DataCoverUtils.desensitizePhoneNumber(houseUserSubDTO.getPhone()));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package cn.com.tenlion.systemhouse.utils.datacover;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 姓名和身份证脱敏工具类
|
||||||
|
*/
|
||||||
|
public class DataCoverUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脱敏人名
|
||||||
|
* @param fullName 完整的人名
|
||||||
|
* @return 脱敏后的人名
|
||||||
|
*/
|
||||||
|
public static String desensitizeName(String fullName) {
|
||||||
|
if (fullName == null || fullName.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将名字拆分为姓和名
|
||||||
|
String[] nameParts = fullName.split(" ");
|
||||||
|
if (nameParts.length == 1) {
|
||||||
|
// 如果只有一个名字,脱敏第二个字符
|
||||||
|
if (nameParts[0].length() > 1) {
|
||||||
|
return nameParts[0].charAt(0) + "*" + nameParts[0].charAt(nameParts[0].length() - 1);
|
||||||
|
} else {
|
||||||
|
// 如果只有一个字符,则直接返回星号
|
||||||
|
return "*";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果有姓和名,脱敏名字中的第一个字符
|
||||||
|
return nameParts[0] + " " + "*" + nameParts[1].charAt(nameParts[1].length() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脱敏身份证号码
|
||||||
|
* @param idCardNumber 完整的身份证号码
|
||||||
|
* @return 脱敏后的身份证号码
|
||||||
|
*/
|
||||||
|
public static String desensitizeIdCardNumber(String idCardNumber) {
|
||||||
|
if (idCardNumber == null || idCardNumber.isEmpty() || idCardNumber.length() != 18) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保留前6位和后4位,中间8位脱敏
|
||||||
|
return idCardNumber.substring(0, 6) + "**********" + idCardNumber.substring(14);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脱敏手机号码
|
||||||
|
* @param phoneNumber 完整的手机号码
|
||||||
|
* @return 脱敏后的手机号码
|
||||||
|
*/
|
||||||
|
public static String desensitizePhoneNumber(String phoneNumber) {
|
||||||
|
if (phoneNumber == null || phoneNumber.isEmpty() || phoneNumber.length() != 11) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保留前3位和后4位,中间4位脱敏
|
||||||
|
return phoneNumber.substring(0, 3) + "****" + phoneNumber.substring(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String fullName = "张三";
|
||||||
|
String idCardNumber = "123456789012345678";
|
||||||
|
|
||||||
|
String desensitizedName = desensitizeName(fullName);
|
||||||
|
String desensitizedIdCardNumber = desensitizeIdCardNumber(idCardNumber);
|
||||||
|
|
||||||
|
System.out.println("原始人名: " + fullName);
|
||||||
|
System.out.println("脱敏后人名: " + desensitizedName);
|
||||||
|
System.out.println("原始身份证号码: " + idCardNumber);
|
||||||
|
System.out.println("脱敏后身份证号码: " + desensitizedIdCardNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
server:
|
server:
|
||||||
port: 8083
|
port: 8083
|
||||||
url: http://192.168.0.111:8083/systemhouse
|
url: http://192.168.0.4:8083/systemhouse
|
||||||
system-title: 房屋管理系统
|
system-title: 房屋管理系统
|
||||||
system-sub-title: 房屋管理系统
|
system-sub-title: 房屋管理系统
|
||||||
nav-page: http://192.168.0.155:7011/usercenter
|
nav-page: http://192.168.0.155:7011/usercenter
|
||||||
@ -125,8 +125,8 @@ security:
|
|||||||
oauth-server: http://192.168.0.155:7011/usercenter
|
oauth-server: http://192.168.0.155:7011/usercenter
|
||||||
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
|
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
|
||||||
client:
|
client:
|
||||||
client-id: 347b893bfd034c43b2349d84c7df1591
|
client-id: 0df0a2df7ffc409ba5ca1b95c64899e4
|
||||||
client-secret: SnJnTWJ2TS9LMGJMZXFobS9kY1NQOHNEa01EVGtaVk9HU1hoMEZNa2RKSGxIdG9KZmEyTjJIRnI0dG1McEdEVA==
|
client-secret: R3ZDY2xDRnlWREZBb2g5SmRscnpuZVhhRjQ1a2RuSXNsWHg5UUN2M09nbmxIdG9KZmEyTjJIRnI0dG1McEdEVA==
|
||||||
user-authorization-uri: ${security.oauth2.oauth-server}/oauth2_client/authorize
|
user-authorization-uri: ${security.oauth2.oauth-server}/oauth2_client/authorize
|
||||||
access-token-uri: ${security.oauth2.oauth-server}/oauth2_client/token
|
access-token-uri: ${security.oauth2.oauth-server}/oauth2_client/token
|
||||||
grant-type: authorization_code
|
grant-type: authorization_code
|
||||||
|
Loading…
Reference in New Issue
Block a user