Commit e85e1d66 authored by 赵啸非's avatar 赵啸非

修改配置文件

parent 58e3a977
......@@ -43,69 +43,6 @@ public class ProxyController {
this.webClient = webClientBuilder.build();
}
/* @PostMapping("/post")
@UnAuth
public Mono<ResponseEntity<String>> proxyPost(
@RequestParam Map<String, String> params, // 透传 URL 参数
@RequestBody(required = false) String body, // 透传 Body
@RequestHeader Map<String, String> headers // 透传 Headers
) {
log.info("proxyPost params: {}, body: {}, headers: {}", params, body, headers);
ApiResp<String> rsp = new ApiResp<>();
String path = params.getOrDefault("path", "");
if (ObjectUtils.isEmpty(path)) {
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg("path is empty!");
return Mono.just(ResponseEntity.ok().body(JSON.toJSONString(rsp)));
}
String method = params.getOrDefault("method", "post");
params.remove("method");
params.remove("path");
String targetUrl = "http://127.0.0.1:11078/basics_api/" + path;
String targetPath = "/basics_api" + path;
log.info("proxyPost targetUrl: {}", targetUrl);
if ("post".equalsIgnoreCase(method)) {
return webClient.post()
.uri(uriBuilder -> {
uriBuilder
.scheme("http")
.host("127.0.0.1")
.port(11078)
.path(targetPath);
params.forEach((key, value) ->
uriBuilder.queryParam(key, UriUtils.encode(value, StandardCharsets.UTF_8))
);
return uriBuilder.build();
})
*//* .uri(uriBuilder -> {
uriBuilder.scheme("http");
uriBuilder.path(targetUrl);
params.forEach((key, value) ->
uriBuilder.queryParam(key, UriUtils.encode(value, StandardCharsets.UTF_8))
);
log.info("proxyPost uriBuilder: {}", uriBuilder.build());
return uriBuilder.build();
})*//*
.headers(httpHeaders -> headers.forEach(httpHeaders::set))
.bodyValue(body != null ? body : "") // 透传 Body
.retrieve()
.toEntity(String.class);
} else if ("get".equalsIgnoreCase(method)) {
} else {
//不支持
}
return Mono.just(ResponseEntity.ok().body(JSON.toJSONString(rsp)));
}*/
@PostMapping("/post")
@UnAuth
......@@ -172,7 +109,6 @@ public class ProxyController {
jsonObject.put("icon", base64Str);
}
}
String qrCode = jsonObject.getString("qrCode");
if (!ObjectUtils.isEmpty(qrCode) && qrCode.startsWith("/file")) {
String filePath = uploadService.getFilePath(qrCode);
......@@ -211,9 +147,6 @@ public class ProxyController {
}
return Rest.ok("透传请求成功!", rspJson.toJSONString());
}
//String resp = HttpUtil.get(urlGet);
return Rest.ok("透传请求成功!", resp);
} catch (Exception e) {
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
......@@ -225,38 +158,10 @@ public class ProxyController {
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg("method is not support!");
return Rest.fail(rsp.getMsg());
// return ResponseEntity.ok().body(JSON.toJSONString(rsp));
}
}
/**
* 添加参数
*
* @param bodyParams
* @return
*/
private String getBodyParams(Map<String, String> bodyParams) {
//1.添加请求参数
//遍历map中所有参数到builder
if (bodyParams != null && bodyParams.size() > 0) {
StringBuffer stringBuffer = new StringBuffer("?");
for (String key : bodyParams.keySet()) {
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(bodyParams.get(key))) {
//如果参数不是null并且不是"",就拼接起来
stringBuffer.append(key);
stringBuffer.append("=");
stringBuffer.append(bodyParams.get(key));
}
}
return stringBuffer.toString();
} else {
return "";
}
}
public static void main(String[] args) {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment