diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java index bf7459f203..a1c2ceb6e8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/OperUserController.java @@ -19,6 +19,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; @@ -80,12 +81,16 @@ public class OperUserController { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); //解密密码 - if (dto.getPassword().length() > 50) { + if (StringUtils.isNotBlank(dto.getPassword()) && dto.getPassword().length() > NumConstant.FIFTY) { String password = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); - String email = RSASignature.decryptByPrivateKey(dto.getEmail(), privateKey); - String phone = RSASignature.decryptByPrivateKey(dto.getPhone(), privateKey); dto.setPassword(password); + } + if (StringUtils.isNotBlank(dto.getEmail()) && dto.getEmail().length() > NumConstant.FIFTY) { + String email = RSASignature.decryptByPrivateKey(dto.getEmail(), privateKey); dto.setEmail(email); + } + if (StringUtils.isNotBlank(dto.getPhone()) && dto.getPhone().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(dto.getPhone(), privateKey); dto.setPhone(phone); } operUserService.save(dto); @@ -93,9 +98,22 @@ public class OperUserController { } @PutMapping - public Result update(@RequestBody OperUserDTO dto) { + public Result update(@RequestBody OperUserDTO dto) throws Exception { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + //解密密码 + if (StringUtils.isNotBlank(dto.getPassword()) && dto.getPassword().length() > NumConstant.FIFTY) { + String password = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); + dto.setPassword(password); + } + if (StringUtils.isNotBlank(dto.getEmail()) && dto.getEmail().length() > NumConstant.FIFTY) { + String email = RSASignature.decryptByPrivateKey(dto.getEmail(), privateKey); + dto.setEmail(email); + } + if (StringUtils.isNotBlank(dto.getPhone()) && dto.getPhone().length() > NumConstant.FIFTY) { + String phone = RSASignature.decryptByPrivateKey(dto.getPhone(), privateKey); + dto.setPhone(phone); + } operUserService.update(dto); return new Result(); }