|
|
@@ -2,6 +2,7 @@ package com.ruoyi.interfaces.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.JsonUtils;
|
|
|
@@ -130,25 +131,10 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
|
|
|
@Override
|
|
|
public String testRun(PtService ptService) throws IOException {
|
|
|
|
|
|
- /* String tokenUrl = "http://localhost:9002/sh-api/login";
|
|
|
- String bodyPar = "{\n" +
|
|
|
- " \"username\": \"admin\",\n" +
|
|
|
- " \"password\": \"Gw#$1601\"\n" +
|
|
|
- "}";
|
|
|
- String token = "";
|
|
|
-
|
|
|
- try {
|
|
|
- token = HttpUtils.sendBodyPostTest(tokenUrl,bodyPar,null);
|
|
|
- System.out.println(token);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- HashMap hashMap = JsonUtils.jsonToPojo(token, HashMap.class);
|
|
|
- String token1 = hashMap.get("token").toString();*/
|
|
|
+ String url = RuoYiConfig.getGatewayUrl() + ptService.getProxyPath() + ptService.getUrl();
|
|
|
HashMap<String, String> headers = new HashMap<>();
|
|
|
- //List<PtServiceParam> ptServiceParams = ptServiceParamMapper.selectAll(ptService.getSrvId());
|
|
|
- //String paramString = ptServiceParams.stream().map(p -> p.getParamCode() + "=" + p.getParamValue()).collect(Collectors.joining());
|
|
|
List<PtServiceParam> params = ptService.getParams();
|
|
|
+ HttpUtils.setGatewayHeaders(headers);
|
|
|
String paramString = "";
|
|
|
switch (ptService.getRqtype()) {
|
|
|
case "POST":
|
|
|
@@ -156,13 +142,13 @@ public class PtServiceServiceImpl extends ServiceImpl<PtServiceMapper, PtService
|
|
|
for (PtServiceParam param : params) {
|
|
|
parMap.put(param.getParamCode(),param.getParamObject());
|
|
|
}
|
|
|
- return HttpUtils.sendBodyPost(ptService.getUrl(),parMap,headers);
|
|
|
+ return HttpUtils.sendBodyPost(url,parMap,headers);
|
|
|
case "GET":
|
|
|
|
|
|
for (PtServiceParam param : params) {
|
|
|
paramString+=(param.getParamCode()+"="+param.getParamValue())+"&";
|
|
|
}
|
|
|
- return HttpUtils.sendGet(ptService.getUrl(),paramString,headers);
|
|
|
+ return HttpUtils.sendGet(url,paramString,headers);
|
|
|
}
|
|
|
return null;
|
|
|
}
|