From 3b74b9452102a0f82ce66d906f488c1359168ab9 Mon Sep 17 00:00:00 2001 From: cxt104926 <1049266034@qq.com> Date: Tue, 29 Jun 2021 21:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/system/UserManagerService.java | 5 +++ .../service/system/vo/StuUserVO.java | 3 ++ .../java/com/stu/stusystem/util/StrUtil.java | 23 ++++++++++++ src/main/resources/mapper/StuMapper.xml | 37 ++++++++++--------- 4 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/stu/stusystem/util/StrUtil.java diff --git a/src/main/java/com/stu/stusystem/service/system/UserManagerService.java b/src/main/java/com/stu/stusystem/service/system/UserManagerService.java index bdc4af2..8d81716 100644 --- a/src/main/java/com/stu/stusystem/service/system/UserManagerService.java +++ b/src/main/java/com/stu/stusystem/service/system/UserManagerService.java @@ -9,6 +9,7 @@ import com.stu.stusystem.service.system.dto.UserManagerDTO; import com.stu.stusystem.service.system.dto.UserManagerQuery; import com.stu.stusystem.service.system.vo.StuUserVO; import com.stu.stusystem.util.CopyBeanUtil; +import com.stu.stusystem.util.StrUtil; import org.apache.shiro.SecurityUtils; import org.apache.shiro.crypto.hash.Sha1Hash; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +39,10 @@ public class UserManagerService { public PageInfo getStuMangerPage(UserManagerQuery query) { PageHelper.startPage(query.getPage(), query.getLimit()); List stuMangerPage = this.stuMapper.getStuMangerPage(query); + for (StuUserVO vo : stuMangerPage) { + String s = StrUtil.hideSix(vo.getIdCard()); + vo.setIdCard(s); + } return new PageInfo<>(stuMangerPage); } diff --git a/src/main/java/com/stu/stusystem/service/system/vo/StuUserVO.java b/src/main/java/com/stu/stusystem/service/system/vo/StuUserVO.java index b64520e..9066213 100644 --- a/src/main/java/com/stu/stusystem/service/system/vo/StuUserVO.java +++ b/src/main/java/com/stu/stusystem/service/system/vo/StuUserVO.java @@ -21,6 +21,9 @@ public class StuUserVO { @ApiModelProperty("班级id") private String classId; + @ApiModelProperty("班级id") + private String className; + @ApiModelProperty("联系电话") private String phone; diff --git a/src/main/java/com/stu/stusystem/util/StrUtil.java b/src/main/java/com/stu/stusystem/util/StrUtil.java new file mode 100644 index 0000000..f51a4cf --- /dev/null +++ b/src/main/java/com/stu/stusystem/util/StrUtil.java @@ -0,0 +1,23 @@ +package com.stu.stusystem.util; + +/** + * @author: cxt + * @time: 2021/6/29 + * 简单的字符串工具类 + */ +public class StrUtil { + + /** + * 隐藏身份证号中间6位 + */ + public static String hideSix(String str) { + if (str.equals("")) { + return ""; + } + if (str.length() == 18){ + return str.replaceAll("(\\d{6})\\d{6}(\\w{6})", "$1******$2"); + }else { + return str.replaceAll("(\\d{5})\\d{5}(\\w{5})", "$1*****$2"); + } + } +} \ No newline at end of file diff --git a/src/main/resources/mapper/StuMapper.xml b/src/main/resources/mapper/StuMapper.xml index b6b48b1..45e81d6 100644 --- a/src/main/resources/mapper/StuMapper.xml +++ b/src/main/resources/mapper/StuMapper.xml @@ -2,24 +2,25 @@ -- GitLab