Commit 0260b797 authored by 赵啸非's avatar 赵啸非

修改配置文件

parent af5c5f43
......@@ -115,6 +115,12 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
</dependencies>
......
package com.mortals.xhx.busiz.web;
import com.alibaba.fastjson.JSON;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriUtils;
import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@RestController
@RequestMapping("/proxy")
@Slf4j
public class ProxyController {
private final WebClient webClient;
public ProxyController(WebClient.Builder webClientBuilder) {
this.webClient = webClientBuilder.build();
}
@PostMapping("/post")
public Mono<ResponseEntity<String>> proxyPost(
@RequestParam Map<String, String> params, // 透传 URL 参数
@RequestBody(required = false) String body, // 透传 Body
@RequestHeader Map<String, String> headers // 透传 Headers
) {
String path = params.getOrDefault("path", "");
ApiResp<String> rsp = new ApiResp<>();
if (!ObjectUtils.isEmpty(path)) {
String targetUrl = "http://127.0.0.1:11072/basic_api/" + path;
return webClient.post()
.uri(uriBuilder -> {
uriBuilder.path(targetUrl);
params.forEach((key, value) ->
uriBuilder.queryParam(key, UriUtils.encode(value, StandardCharsets.UTF_8))
);
return uriBuilder.build();
})
.headers(httpHeaders -> headers.forEach(httpHeaders::set))
.bodyValue(body != null ? body : "") // 透传 Body
.retrieve()
.toEntity(String.class);
} else {
rsp.setCode(ApiRespCodeEnum.FAILED.getValue());
rsp.setMsg("path is empty!");
return Mono.just(ResponseEntity.ok().body(JSON.toJSONString(rsp)));
}
}
}
###区域列表
POST {{baseUrl}}/area/interlist
Content-Type: application/json
{
"page":1,
"size":-1,
"areaLevelList":[2,3]
}
###区域更新与保存
POST {{baseUrl}}/area/save
Content-Type: application/json
{
"id": 36357,
"ancestors":"xk5j2k",
"name":"11111111111",
"iid":"4eeoc8",
"pid":"0",
"haveSonArea":"True",
"haveSonDept":"True",
"haveGetDept":"True",
"haveGetMatterList":"True",
"areaCode":"gm0rjt",
"areaLevel":1,
"shortName":"694fo7",
"domain":"ml27ym",
"status":1
}
> {%
client.global.set("Area_id", JSON.parse(response.body).data.id);
%}
###区域查看
GET {{baseUrl}}/area/info?id={{Area_id}}
Accept: application/json
###区域编辑
GET {{baseUrl}}/area/edit?id={{Area_id}}
Accept: application/json
###区域删除
GET {{baseUrl}}/area/delete?id={{Area_id}}
Accept: application/json
###区域查看
GET {{baseUrl}}/area/getListByRootId?rootId=0
Accept: application/json
###区域查看
POST {{baseUrl}}/area/treeselect
Accept: application/json
###区域查看
GET {{baseUrl}}/area/getListByParentId?parentId=8fc9422b1bca40fa86f12b028b33e6cf
Accept: application/json
......@@ -6,7 +6,7 @@ POST {{baseUrl}}/basics_api/base/matter/interlist
Content-Type: application/json
{
"areaLevel": 5
"areaLevel": 2
}
......
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