From a210d5734d6d332e31fb74bdefdcc5c6106c1799 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Thu, 12 Sep 2024 16:45:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E3=80=81=E8=BD=A6?= =?UTF-8?q?=E7=89=8C=E5=8F=B7=E5=8A=A0=E5=AF=86=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/utils/aes/SM4Utils.java | 3 +++ .../background/service/impl/HumanServiceImpl.java | 10 ++++------ .../background/service/impl/TeamServiceImpl.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/SM4Utils.java b/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/SM4Utils.java index 9c08d48..4780323 100644 --- a/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/SM4Utils.java +++ b/securitycontrol-commons/securitycontrol-commons-core/src/main/java/com/securitycontrol/common/core/utils/aes/SM4Utils.java @@ -221,6 +221,9 @@ public class SM4Utils { * @date 2024/9/12 10:37 */ public static String encryptData(String data) { + if(StringUtils.isBlank(data)){ + return null; + } String lm = "щ"; String value = decryptData_CBC(data); if(StringUtils.isBlank(value) || Objects.equals(lm,value)){ diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java index 70d731f..1bdd299 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/HumanServiceImpl.java @@ -132,7 +132,8 @@ public class HumanServiceImpl implements HumanService { } } } - vo.setIdNumber(AesCbcUtils.encrypt(vo.getIdNumber())); + vo.setIdNumber(SM4Utils.encryptData_CBC(vo.getIdNumber())); + vo.setPhone(SM4Utils.encryptData_CBC(vo.getPhone())); // 保存人员数据 mapper.addOrUpdatePersonnel(vo); } catch (Exception e) { @@ -160,7 +161,7 @@ public class HumanServiceImpl implements HumanService { public Boolean userIsExist(List> list, String idNumber) { for (Map map : list) { String value = map.get("value"); - String decryptValue = AesCbcUtils.decrypt(value); + String decryptValue = SM4Utils.decryptData_CBC(value); if (decryptValue == null) { if (Objects.equals(idNumber, value)) { return true; @@ -179,10 +180,7 @@ public class HumanServiceImpl implements HumanService { HumanManageVo vo = new HumanManageVo(); try { vo = mapper.getPersonnelById(dto); - String decryptIdNumber = AesCbcUtils.decrypt(vo.getIdNumber()); - if(decryptIdNumber != null){ - vo.setIdNumber(decryptIdNumber); - } + vo.setIdNumber(SM4Utils.encryptData(vo.getIdNumber())); List resourceFileVos = mapper.getFiles(vo.getUserId()); if (CollectionUtils.isNotEmpty(resourceFileVos)) { List list = new ArrayList<>(); diff --git a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/TeamServiceImpl.java b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/TeamServiceImpl.java index 4df3a5d..7dc7d63 100644 --- a/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/TeamServiceImpl.java +++ b/securitycontrol-model/securitycontrol-background/src/main/java/com/securitycontrol/background/service/impl/TeamServiceImpl.java @@ -102,7 +102,7 @@ public class TeamServiceImpl implements TeamService { public Boolean teamIsExist(List> list, String idNumber) { for (Map map : list) { String value = map.get("value"); - String decryptValue = AesCbcUtils.decrypt(value); + String decryptValue = SM4Utils.decryptData_CBC(value); if (decryptValue == null) { if (Objects.equals(idNumber, value)) { return true;