【add】查询全部用户id的接口开发完毕
This commit is contained in:
+37
@@ -14,6 +14,8 @@ import com.jero.modules.docking.iam.po.encrypt.AcceptEncryptPo;
|
|||||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||||
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabels;
|
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabels;
|
||||||
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabelsHeader;
|
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabelsHeader;
|
||||||
|
import com.jero.modules.docking.iam.po.encrypt.SendPoEncryptPo;
|
||||||
|
import com.jero.modules.docking.utils.BamboocloudUtils;
|
||||||
import com.jero.modules.docking.utils.DockingConstant;
|
import com.jero.modules.docking.utils.DockingConstant;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -29,6 +31,16 @@ public class TestClient {
|
|||||||
// testClient.sendUserCreate(); // 创建用户接口测试
|
// testClient.sendUserCreate(); // 创建用户接口测试
|
||||||
testClient.sendUserUpdate(); // 更新用户接口测试
|
testClient.sendUserUpdate(); // 更新用户接口测试
|
||||||
testClient.sendOrgCreate(); // 组织创建接口测试
|
testClient.sendOrgCreate(); // 组织创建接口测试
|
||||||
|
testClient.sendQueryAllUserIdsService(); // 查询所有用户ID接口测试
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对数据解密
|
||||||
|
private void decryptData(String encryptData) throws JsonProcessingException {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
SendPoEncryptPo sendPoEncryptPo = objectMapper.readValue(encryptData, SendPoEncryptPo.class);
|
||||||
|
String decrypt = BamboocloudUtils.getPlaintext(sendPoEncryptPo.getReturns().getData(), DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||||
|
|
||||||
|
System.out.println("解密后数据:" + decrypt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,4 +202,29 @@ public class TestClient {
|
|||||||
System.out.println("组织创建接口响应:" + response);
|
System.out.println("组织创建接口响应:" + response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取全部用户id
|
||||||
|
*/
|
||||||
|
private void sendQueryAllUserIdsService() throws JsonProcessingException {
|
||||||
|
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryAllUserIdsService";
|
||||||
|
|
||||||
|
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||||
|
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||||
|
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||||
|
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||||
|
|
||||||
|
// 加密数据
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||||
|
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||||
|
|
||||||
|
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||||
|
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||||
|
|
||||||
|
String response = HttpUtil.post(url, sendPoDataJson);
|
||||||
|
System.out.println("查询全部用的id接口响应:" + response);
|
||||||
|
|
||||||
|
this.decryptData(response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+35
@@ -392,4 +392,39 @@ public class SyncIamController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询全部用的id
|
||||||
|
* @param iamCommon
|
||||||
|
* @return
|
||||||
|
* @throws JsonProcessingException
|
||||||
|
*/
|
||||||
|
@PostMapping({"/QueryAllUserIdsService"})
|
||||||
|
public SendPoEncryptPo QueryAllUserIdsService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||||
|
if (iamCommon == null
|
||||||
|
|| iamCommon.getMessageEncryptTabels() == null
|
||||||
|
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||||
|
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||||
|
throw new IamGlobalException(null, this.paramNotGetError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对核心数据解密
|
||||||
|
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||||
|
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||||
|
|
||||||
|
// 校验身份认证,确保接口正确 必须调用!
|
||||||
|
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||||
|
|
||||||
|
// 处理业务逻辑,封装字段
|
||||||
|
IamUserIdListResponse userIdListResponse = this.syncIamService.getAllUserIds(commonAcceptDto);
|
||||||
|
|
||||||
|
// 处理统一响应PO层,并加密业务字段
|
||||||
|
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||||
|
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, userIdListResponse);
|
||||||
|
|
||||||
|
return sendPoEncryptPo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package com.jero.modules.docking.iam.dto.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织机构创建的响应体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class IamUserIdListResponse extends IamCommonResponseDto{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户创建后生成的id
|
||||||
|
*/
|
||||||
|
private List<String> userIdList;
|
||||||
|
|
||||||
|
}
|
||||||
+2
@@ -2,11 +2,13 @@ package com.jero.modules.docking.iam.po.encrypt;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回数据的Return层
|
* 返回数据的Return层
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
public class SendEncryptReturnsPo {
|
public class SendEncryptReturnsPo {
|
||||||
|
|
||||||
@JsonProperty("data")
|
@JsonProperty("data")
|
||||||
|
|||||||
+20
@@ -42,6 +42,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IAM对接业务处理类
|
* IAM对接业务处理类
|
||||||
@@ -903,4 +904,23 @@ public class SyncIamService {
|
|||||||
return BpmcResponseDto.success();
|
return BpmcResponseDto.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回全部用户的id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IamUserIdListResponse getAllUserIds(IamCommonAcceptDto commonAcceptDto){
|
||||||
|
QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<SysUser>();
|
||||||
|
userQueryWrapper.select("id");
|
||||||
|
// 获取全部用户的id,得到一个String的list
|
||||||
|
List<String> userIds = this.sysUserService.list(userQueryWrapper).stream().map(SysUser::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
IamUserIdListResponse iamUserIdListResponse = new IamUserIdListResponse();
|
||||||
|
iamUserIdListResponse.setUserIdList(userIds);
|
||||||
|
iamUserIdListResponse.setBimRequestId(commonAcceptDto.getBimRequestId());
|
||||||
|
iamUserIdListResponse.setResultCode(DockingConstant.IAM_SUCCESS_RESULT_CODE);
|
||||||
|
iamUserIdListResponse.setMessage(DockingConstant.IAM_SUCCESS_MESSAGE);
|
||||||
|
|
||||||
|
return iamUserIdListResponse;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user