|
@@ -56,6 +56,11 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
*/
|
|
|
public static final String ORG_SYNC_API = "/api/org-service/v3/orgs/search";
|
|
|
|
|
|
+ /**
|
|
|
+ * 警员详情PI
|
|
|
+ */
|
|
|
+ public static final String POLICE_DETAIL_API = "/api/user-service/v3/users/police/%s";
|
|
|
+
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
private ApproveProperties approveProperties;
|
|
@@ -85,7 +90,7 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
//构建请求头
|
|
|
|
|
|
HttpEntity<Map<String, Object>> requestEntity;
|
|
|
-
|
|
|
+
|
|
|
SecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
if (ObjectUtil.isNotNull(currentUser)) {
|
|
|
HttpHeaders headers = ProofsUtil.buildHttpHeaders(currentUser);
|
|
@@ -116,7 +121,7 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
@Override
|
|
|
public ApiOrgResultVo orgInfo(String orgCode) {
|
|
|
//构建请求头
|
|
|
-
|
|
|
+
|
|
|
HttpEntity<Map<String, Object>> requestEntity;
|
|
|
SecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
if (ObjectUtil.isNotNull(currentUser)) {
|
|
@@ -152,7 +157,7 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
|
|
|
String userServiceUrl = approveProperties.getUserServiceUrl();
|
|
|
String url = userServiceUrl + ORG_SYNC_API;
|
|
|
-
|
|
|
+
|
|
|
HttpHeaders httpHeaders = HttpHeaders.EMPTY;
|
|
|
SecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
if (ObjectUtil.isNotNull(currentUser)) {
|
|
@@ -188,10 +193,46 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiPoliceResultVo policeDetailByIdcard(String searchIdcard) {
|
|
|
+ Assert.notBlank(searchIdcard);
|
|
|
+ String requestName = "获取警员详情";
|
|
|
+
|
|
|
+ HttpEntity<Map<String, Object>> requestEntity;
|
|
|
+
|
|
|
+ SecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
+ if (ObjectUtil.isNotNull(currentUser)) {
|
|
|
+ HttpHeaders headers = ProofsUtil.buildHttpHeaders(currentUser);
|
|
|
+ requestEntity = new HttpEntity<>(headers);
|
|
|
+ } else {
|
|
|
+ requestEntity = new HttpEntity<>(Collections.emptyMap());
|
|
|
+ }
|
|
|
+ //远程调用用户中心接口
|
|
|
+ String userServiceUrl = approveProperties.getUserServiceUrl();
|
|
|
+ String url = userServiceUrl + String.format(POLICE_DETAIL_API, searchIdcard);
|
|
|
+ logger.info("向认证服务查询" + requestName + "请求路径:{}", url);
|
|
|
+ ResponseEntity<String> resEntity = restTemplate.exchange(url, HttpMethod.GET, requestEntity, String.class);
|
|
|
+ logger.info("向认证服务查询" + requestName + "返回结果resEntity=【{}】,请求url=【{}】", JSONObject.toJSONString(resEntity), url);
|
|
|
+ //判断请求是否成功
|
|
|
+ ApiPoliceResultVo oauthUserVO = null;
|
|
|
+ if (resEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
+ ResponseDTO<OauthUserVO> responseDTO = JSONObject.parseObject(resEntity.getBody(), ResponseDTO.class);
|
|
|
+ if (responseDTO != null) {
|
|
|
+ if (ResponseUtil.isSuccess(responseDTO)) {
|
|
|
+ responseDTO.getResult();
|
|
|
+ oauthUserVO = JSONObject.parseObject(JSON.toJSONString(responseDTO.getResult()), ApiPoliceResultVo.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return oauthUserVO;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@SneakyThrows(JsonProcessingException.class)
|
|
|
public ApiResultPage<ApiPoliceResultVo> policePage(ApiSearchReq apiSearchReq) {
|
|
|
Assert.notNull(apiSearchReq);
|
|
|
+ String requestName = "获取警员列表";
|
|
|
|
|
|
String userServiceUrl = approveProperties.getUserServiceUrl();
|
|
|
String url = userServiceUrl + POLICE_SYNC_API;
|
|
@@ -203,23 +244,23 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
}
|
|
|
|
|
|
RequestEntity<ApiSearchReq> apiSearchReqRequestEntity = new RequestEntity<>(apiSearchReq, httpHeaders, HttpMethod.POST, URI.create(url));
|
|
|
- logger.info("请求人员信息参数:{}", JsonUtils.toJSONString(apiSearchReqRequestEntity));
|
|
|
+ logger.info(requestName + "参数:{}", JsonUtils.toJSONString(apiSearchReqRequestEntity));
|
|
|
ResponseEntity<String> resEntity = restTemplate.exchange(apiSearchReqRequestEntity, String.class);
|
|
|
String jsonString = JsonUtils.toJSONString(resEntity);
|
|
|
- logger.info("请求人员信息返回参数:{}", jsonString);
|
|
|
+ logger.info(requestName + "返回参数:{}", jsonString);
|
|
|
if (!resEntity.getStatusCode().is2xxSuccessful()) {
|
|
|
- logger.error("请求获取机构信息错误:{}", jsonString);
|
|
|
+ logger.error(requestName + "信息错误:{}", jsonString);
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
String body = resEntity.getBody();
|
|
|
ApiResult apiResult = JSONObject.parseObject(body, ApiResult.class);
|
|
|
if (ObjectUtil.isNull(apiResult)) {
|
|
|
- logger.error("请求获取人员信息错误:{}", body);
|
|
|
+ logger.error(requestName + "信息错误:{}", body);
|
|
|
return null;
|
|
|
}
|
|
|
if (!apiResult.getStatusCode().equalsIgnoreCase(ResponseStatus.SUCCESS_CODE)) {
|
|
|
- logger.error("请求获取人员信息错误:{}", body);
|
|
|
+ logger.error(requestName + "信息错误:{}", body);
|
|
|
return null;
|
|
|
}
|
|
|
|