Browse Source

微调后门外部调用方法

dev_shibei_match
jianjun 5 years ago
parent
commit
fd678eddb7
  1. 4
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/backdoor/BackDoorController.java
  2. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/BackDoorService.java
  3. 6
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java
  4. 4
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java

4
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/backdoor/BackDoorController.java

@ -27,9 +27,9 @@ public class BackDoorController {
* @date 2020/10/23 1:44 下午
*/
@PostMapping("redirect/external")
public String backDoor(@RequestHeader(value = "Data-Type", defaultValue = "real", required = false) String dataType,
public Object backDoor(@RequestHeader(value = "Data-Type", defaultValue = "real", required = false) String dataType,
@RequestHeader("AppId") String appId, @RequestHeader("target") String target,
@RequestBody(required = false) String targetParam) {
@RequestBody(required = false) Object targetParam) {
return backDoorService.redirect(dataType, appId, target, targetParam);
}

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/BackDoorService.java

@ -6,6 +6,6 @@ package com.epmet.datareport.service.backdoor;
*/
public interface BackDoorService {
String redirect(String dataType, String appId, String target, String o);
Object redirect(String dataType, String appId, String target, Object o);
}

6
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java

@ -27,7 +27,7 @@ public class BackDoorServiceImpl implements BackDoorService {
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public String redirect(String dataType, String appId, String target, String targetParam) {
public Object redirect(String dataType, String appId, String target, Object targetParam) {
Result<AppIdInfoResultDTO> appIdInfoResultDTOResult = commonServiceOpenFeignClient.appIdInfo(appId);
if (!appIdInfoResultDTOResult.success()) {
throw new RenException("获取accessToken失败......");
@ -39,11 +39,11 @@ public class BackDoorServiceImpl implements BackDoorService {
headerMap.put("AppId", data.getAppId());
headerMap.put("AuthType", "jwt");
headerMap.put("Data-Type",dataType);
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, targetParam, 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());
}
return stringResult.getData();
return JSON.parseObject(stringResult.getData());
}
}

4
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java

@ -90,4 +90,8 @@ public class ExtAppJwtTokenUtils {
return createToken(claim, secret);
}
public static void main(String[] args) {
genTestToken();
}
}

Loading…
Cancel
Save