Commit 927d130d by 刘鑫

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
2 parents b856e715 34cb7433
......@@ -16,21 +16,12 @@
package com.dituhui.pea.gateway.config;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.PostConstruct;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule;
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.BlockRequestHandler;
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import com.alibaba.csp.sentinel.adapter.gateway.sc.exception.SentinelGatewayBlockExceptionHandler;
import reactor.core.publisher.Mono;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Bean;
......@@ -47,6 +38,13 @@ import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerResponse;
import org.springframework.web.reactive.result.view.ViewResolver;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author TrevorLink
......@@ -113,4 +111,9 @@ public class GatewayConfig {
return new CorsWebFilter(source);
}
@Bean
public GlobalRequestUrlDecodeFilter globalRequestUrlDecodeFilter() {
return new GlobalRequestUrlDecodeFilter();
}
}
package com.dituhui.pea.gateway.config;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import reactor.core.publisher.Mono;
import java.net.URI;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
* URI 参数过滤
*
* @author lsy_xin 2022/3/3 16:29:29
*/
@Slf4j
@AllArgsConstructor
public class GlobalRequestUrlDecodeFilter implements GlobalFilter, Ordered {
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
URI uri = request.getURI();
String path = uri.getPath();
String decodePath = URLDecoder.decode(path, StandardCharsets.UTF_8);
ServerHttpRequest newRequest = exchange.getRequest().mutate().path(decodePath).build();
return chain.filter(exchange.mutate().request(newRequest).build());
}
@Override
public int getOrder() {
return Integer.MIN_VALUE + 1;
}
}
package com.dituhui.pea.order.controller;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.OrganizationTreeDTO;
......@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.Duration;
import java.time.Period;
import java.time.ZoneId;
import java.util.Date;
......@@ -102,10 +104,9 @@ public class PeaApiController {
@PostMapping("/capacity/query")
public Result<CapacityQueryDTO.Result> capacityQuery(@Validated @RequestBody CapacityQueryDTO.Request reqDTO) {
//查询日期起止参数限制为一月
Period between = Period.between(DateUtil.fromDate(reqDTO.getBeginDate()).toLocalDate(), DateUtil.fromDate(reqDTO.getEndDate()).toLocalDate());
if (between.getMonths() > 1) {
throw new BusinessException("查询日期起止参数限制为一月");
}
CapacityQueryDTO.Result result = new CapacityQueryDTO.Result();
......
......@@ -72,13 +72,13 @@ public class OrderDTO {
* 产品类别
*/
@NotBlank
private String product_type;
private String productType;
/**
* 服务类型
*/
@NotBlank
private String service_type;
private String serviceType;
/**
* 故障描述
*/
......
{
"serverUrl": "http://{{server}}",
"serverEnv": "http://{{server}}",
"serverUrl": "https://{{server}}",
"serverEnv": "https://{{server}}",
"pathPrefix": "",
"isStrict": false,
"allInOne": true,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!