Browse Source

backDoor

master
zxc 5 years ago
parent
commit
f9e0390959
  1. 9
      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. 14
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/backdoor/impl/BackDoorServiceImpl.java

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

@ -3,10 +3,7 @@ package com.epmet.datareport.controller.backdoor;
import com.epmet.commons.tools.utils.Result;
import com.epmet.datareport.service.backdoor.BackDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @Author zxc
@ -20,8 +17,8 @@ public class BackDoorController {
private BackDoorService backDoorService;
@PostMapping("backdoor")
public Result backDoor(@RequestHeader("Data-Type")String dataType, @RequestHeader("AppId")String appId, @RequestHeader("target")String target){
return new Result().ok(backDoorService.backDoor(dataType,appId,target));
public Result backDoor(@RequestHeader("Data-Type")String dataType, @RequestHeader("AppId")String appId, @RequestHeader("target")String target, @RequestBody Object o){
return new Result().ok(backDoorService.backDoor(dataType,appId,target,o));
}
}

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

@ -8,6 +8,6 @@ import com.epmet.commons.tools.utils.Result;
*/
public interface BackDoorService {
Object backDoor(String dataType, String appId, String target);
Object backDoor(String dataType, String appId, String target, Object o);
}

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

@ -9,6 +9,7 @@ import com.epmet.datareport.constant.*;
import com.epmet.datareport.service.backdoor.BackDoorService;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -20,30 +21,31 @@ import java.util.Map;
* @DateTime 2020/10/21 5:17 下午
*/
@Service
@Slf4j
public class BackDoorServiceImpl implements BackDoorService {
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public Object backDoor(String dataType, String appId, String target) {
public Object backDoor(String dataType, String appId, String target, Object o) {
Result<AppIdInfoResultDTO> appIdInfoResultDTOResult = commonServiceOpenFeignClient.appIdInfo(appId);
if (!appIdInfoResultDTOResult.success()){
throw new RenException("获取accessToken失败......");
}
AppIdInfoResultDTO data = appIdInfoResultDTOResult.getData();
String url = FactConstant.URL.concat(target);
Map map = new HashMap(16);
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);
// headerMap.put("Authorization","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhcHAiOiJnb3YiLCJjbGllbnQiOiJ3eG1wIiwiZXhwIjoxNjAzODY2MjY2LCJ1c2VySWQiOiI0ZWYwYTA4YTBiNWVmOTM0ZjBiOGE4YzQ2ODJjMzY2NSIsImlhdCI6MTYwMzI2MTQ2Nn0.pW1Wzss-xtj6vUuJbvglUltdDWlUKqTyVQ6rGQ7WpSaE_Iz1uAd5XWI5OGLajyU4-aYCW14Dw3C-XoFepyiZJQ");
map.put("bizType","community");
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(map),headerMap);
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(o),headerMap);
log.info(JSON.toJSONString(stringResult),stringResult.error());
if (!stringResult.success()){
throw new RenException("请求【"+url+"】失败......"+stringResult.error());
}
JSONObject jsonObject = JSON.parseObject(stringResult.getData());
System.out.println(jsonObject);
return jsonObject;
}
}

Loading…
Cancel
Save