【添加】处理 邮箱和手机号 更新的加密bug
This commit is contained in:
+32
-1
@@ -25,7 +25,8 @@ public class TestClient {
|
||||
|
||||
public static void main(String[] args) throws JsonProcessingException {
|
||||
TestClient testClient = new TestClient();
|
||||
testClient.sendUserCreate(); // 创建用户接口测试
|
||||
// testClient.sendUserCreate(); // 创建用户接口测试
|
||||
testClient.sendUserUpdate(); // 更新用户接口测试
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,4 +109,34 @@ public class TestClient {
|
||||
System.out.printf("用户创建接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户更新测试
|
||||
*/
|
||||
private void sendUserUpdate() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setBimUid("1709786346053017601"); // 数据库中取到的ID
|
||||
iamUserAcceptDto.setSrmsPost("科长");
|
||||
iamUserAcceptDto.setSrmsUpdateTime("2023-10-15 10:35:20"); // 测试不发送UpdateTime的情况
|
||||
iamUserAcceptDto.setSrmsEntryTime("2020-11-12");
|
||||
|
||||
iamUserAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptPoSystemPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserUpdateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.printf("用户创建接口响应:" + response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+33
-24
@@ -169,31 +169,40 @@ public class SyncIamController {
|
||||
|
||||
@PostMapping({"/OrgCreateService"})
|
||||
public SendPoSystemPo orgCreateService(@RequestBody AcceptPoSystemPo iamOrgInfo) throws JsonProcessingException {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageTabels() == null
|
||||
|| iamOrgInfo.getMessageTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
IamOrgAcceptDto orgAcceptDto = null;
|
||||
try {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageTabels() == null
|
||||
|| iamOrgInfo.getMessageTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储组织,返回组织id
|
||||
IamOrgCreateResponse iamOrgCreateResponse = this.syncIamService.orgCreateService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoSystemPo sendPoSystemPo = this.syncIamService.handlerGloablResponse(acceptMessageHeader, iamOrgCreateResponse);
|
||||
return sendPoSystemPo;
|
||||
} catch (DuplicateKeyException duplicateKeyException) {
|
||||
log.error("数据库值重复:{}", duplicateKeyException.getMessage());
|
||||
if (orgAcceptDto != null) {
|
||||
throw new IamGlobalException(orgAcceptDto.getBimRequestId(), "数据库值重复,请检查组织编号【" + orgAcceptDto.getSrmsOrgCode() + "】是否异常");
|
||||
} else {
|
||||
throw new IamGlobalException(null, "未知异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储组织,返回组织id
|
||||
IamOrgCreateResponse iamOrgCreateResponse = this.syncIamService.orgCreateService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoSystemPo sendPoSystemPo = this.syncIamService.handlerGloablResponse(acceptMessageHeader, iamOrgCreateResponse);
|
||||
|
||||
return sendPoSystemPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/OrgUpdateService"})
|
||||
|
||||
+3
-6
@@ -266,13 +266,10 @@ public class SyncIamService {
|
||||
sysUser.setSex(Integer.valueOf(userAcceptDto.getSrmsSex()));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(userAcceptDto.getSrmsEmail())){
|
||||
sysUser.setEmail(userAcceptDto.getSrmsEmail());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(userAcceptDto.getSrmsPhone())){
|
||||
sysUser.setPhone(userAcceptDto.getSrmsPhone());
|
||||
}
|
||||
// 手机号 和 邮箱有加密,需要单独处理
|
||||
sysUser.setEmail(userAcceptDto.getSrmsEmail());
|
||||
sysUser.setPhone(userAcceptDto.getSrmsPhone());
|
||||
|
||||
if (StrUtil.isNotEmpty(userAcceptDto.getSrmsStatus())){
|
||||
if ("1".equals(userAcceptDto.getSrmsStatus())){
|
||||
|
||||
Reference in New Issue
Block a user