帮我把地址上链接口 单独分出来一个接口,同时修改对应文档
This commit is contained in:
1 parent
fbc72b5b57
commit
dc2564b1d4
4 files changed
+90
-9
No files matched your search
@@ -41,6 +41,20 @@ public class RentalApiController {
|
||||
@PostMapping(value = "/{operation}", consumes = "application/json")
|
||||
public AjaxResult execute(@PathVariable String operation, HttpServletRequest request)
|
||||
throws Exception {
|
||||
return executeOperation(operation, request, false);
|
||||
}
|
||||
|
||||
/** 地址上链独立入口;认证仍覆盖实际请求URI,不能使用资源租赁路径的签名。 */
|
||||
@PostMapping(value = "/address-onchain/{operation}", consumes = "application/json")
|
||||
public AjaxResult executeOnchain(@PathVariable String operation, HttpServletRequest request)
|
||||
throws Exception {
|
||||
require(Arrays.asList("quote", "create", "query").contains(operation), "不支持的地址上链接口");
|
||||
return executeOperation(operation, request, true);
|
||||
}
|
||||
|
||||
/** 复用原始请求读取、凭证校验和订单服务,按入口强制隔离订单类型。 */
|
||||
private AjaxResult executeOperation(String operation, HttpServletRequest request, boolean addressOnchain)
|
||||
throws Exception {
|
||||
require(
|
||||
Arrays.asList("create", "query", "packages", "quote").contains(operation)
|
||||
&& request.getQueryString() == null,
|
||||
@@ -77,6 +91,11 @@ public class RentalApiController {
|
||||
Map<String, Object> data =
|
||||
json.readValue(body, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
String expectedType = addressOnchain ? RentalOnchain.ORDER_TYPE : "RESOURCE_RENTAL";
|
||||
require(text(data, "order_type").isEmpty() || expectedType.equals(text(data, "order_type")),
|
||||
addressOnchain ? "地址上链接口仅支持ADDRESS_ONCHAIN" : "地址上链请使用/api/rental/v1/address-onchain接口");
|
||||
// 类型由路由确定;无需客户端通过通用接口选择转账业务。
|
||||
data.put("order_type", expectedType);
|
||||
if ("packages".equals(operation)) {
|
||||
List<Map<String, Object>> products =
|
||||
store.rows(
|
||||
@@ -125,6 +144,7 @@ public class RentalApiController {
|
||||
app.get("id"),
|
||||
input(data, "merchant_order_no", 64));
|
||||
require(order != null, "订单不存在");
|
||||
require(addressOnchain == RentalOnchain.isOrder(order), "订单类型与接口不匹配");
|
||||
}
|
||||
return AjaxResult.success(
|
||||
map(
|
||||
|
||||
Reference in new issue
Block a user