|
|
@ -1,11 +1,10 @@ |
|
|
|
package com.epmet.datareport.service.backdoor.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.datareport.constant.*; |
|
|
|
import com.epmet.datareport.constant.FactConstant; |
|
|
|
import com.epmet.datareport.service.backdoor.BackDoorService; |
|
|
|
import com.epmet.dto.result.AppIdInfoResultDTO; |
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
@ -28,24 +27,23 @@ public class BackDoorServiceImpl implements BackDoorService { |
|
|
|
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object backDoor(String dataType, String appId, String target, Object o) { |
|
|
|
public Object redirect(String dataType, String appId, String target, Object targetParam) { |
|
|
|
Result<AppIdInfoResultDTO> appIdInfoResultDTOResult = commonServiceOpenFeignClient.appIdInfo(appId); |
|
|
|
if (!appIdInfoResultDTOResult.success()){ |
|
|
|
if (!appIdInfoResultDTOResult.success()) { |
|
|
|
throw new RenException("获取accessToken失败......"); |
|
|
|
} |
|
|
|
AppIdInfoResultDTO data = appIdInfoResultDTOResult.getData(); |
|
|
|
String url = FactConstant.URL.concat(target); |
|
|
|
Map<String,String> headerMap = new HashMap<>(16); |
|
|
|
headerMap.put("AccessToken",data.getAccessToken()); |
|
|
|
headerMap.put("AppId",data.getAppId()); |
|
|
|
headerMap.put("AuthType","jwt"); |
|
|
|
Map<String, String> headerMap = new HashMap<>(16); |
|
|
|
headerMap.put("AccessToken", data.getAccessToken()); |
|
|
|
headerMap.put("AppId", data.getAppId()); |
|
|
|
headerMap.put("AuthType", "jwt"); |
|
|
|
headerMap.put("Data-Type",dataType); |
|
|
|
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(o),headerMap); |
|
|
|
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(targetParam), headerMap); |
|
|
|
log.info(JSON.toJSONString(stringResult)); |
|
|
|
if (!stringResult.success()){ |
|
|
|
throw new RenException("请求【"+url+"】失败......"+stringResult.error()); |
|
|
|
} |
|
|
|
JSONObject jsonObject = JSON.parseObject(stringResult.getData()); |
|
|
|
return jsonObject; |
|
|
|
return JSON.parseObject(stringResult.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|