forked from rongchao/epmet-cloud-rizhao
18 changed files with 240 additions and 17 deletions
@ -0,0 +1,22 @@ |
|||
package com.epmet.evaluationindex.screen.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2020/10/22 10:52 上午 |
|||
*/ |
|||
@Data |
|||
public class TreeByTypeFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -1438758394814978472L; |
|||
|
|||
public interface TreeByType extends CustomerClientShowGroup{} |
|||
|
|||
@NotBlank(message = "bizType不能为空",groups = TreeByType.class) |
|||
private String bizType; |
|||
} |
@ -0,0 +1,27 @@ |
|||
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; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2020/10/21 5:17 下午 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("backdoor") |
|||
public class BackDoorController { |
|||
|
|||
@Autowired |
|||
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)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.datareport.service.backdoor; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2020/10/21 5:17 下午 |
|||
*/ |
|||
public interface BackDoorService { |
|||
|
|||
Object backDoor(String dataType, String appId, String target); |
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
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.service.backdoor.BackDoorService; |
|||
import com.epmet.dto.result.AppIdInfoResultDTO; |
|||
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2020/10/21 5:17 下午 |
|||
*/ |
|||
@Service |
|||
public class BackDoorServiceImpl implements BackDoorService { |
|||
|
|||
@Autowired |
|||
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|||
|
|||
@Override |
|||
public Object backDoor(String dataType, String appId, String target) { |
|||
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); |
|||
JSONObject jsonObject = JSON.parseObject(stringResult.getData()); |
|||
System.out.println(jsonObject); |
|||
return jsonObject; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2020/10/21 5:30 下午 |
|||
*/ |
|||
@Data |
|||
public class AppIdInfoResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 4556971930323763712L; |
|||
|
|||
/** |
|||
* 应用ID |
|||
*/ |
|||
private String appId; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 密钥 |
|||
*/ |
|||
private String secret; |
|||
|
|||
private String accessToken; |
|||
} |
Loading…
Reference in new issue