Browse Source

fix:增加token过期的key

visual
pref_mail@163.com 3 months ago
parent
commit
e462b94fe5
  1. 8
      blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java
  2. 1
      blade-gateway/src/main/java/org/springblade/gateway/filter/RequestFilter.java
  3. 3
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java
  4. 2
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReservationPlanReportListener.java

8
blade-gateway/src/main/java/org/springblade/gateway/filter/AuthFilter.java

@ -33,7 +33,9 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
@ -61,6 +63,10 @@ public class AuthFilter implements GlobalFilter, Ordered {
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
//校验 Token 放行 //校验 Token 放行
String originalRequestUrl = RequestProvider.getOriginalRequestUrl(exchange); String originalRequestUrl = RequestProvider.getOriginalRequestUrl(exchange);
// ServerHttpRequest request = exchange.getRequest();
// HttpHeaders headers = request.getHeaders();
// headers.add("hwy_req","1");
String path = exchange.getRequest().getURI().getPath(); String path = exchange.getRequest().getURI().getPath();
if (isSkip(path) || isSkip(originalRequestUrl)) { if (isSkip(path) || isSkip(originalRequestUrl)) {
return chain.filter(exchange); return chain.filter(exchange);
@ -88,6 +94,8 @@ public class AuthFilter implements GlobalFilter, Ordered {
return unAuth(resp, "令牌已失效"); return unAuth(resp, "令牌已失效");
} }
} }
return chain.filter(exchange); return chain.filter(exchange);
} }

1
blade-gateway/src/main/java/org/springblade/gateway/filter/RequestFilter.java

@ -40,6 +40,7 @@ public class RequestFilter implements GlobalFilter, Ordered {
// 1. 清洗请求头中from 参数 // 1. 清洗请求头中from 参数
ServerHttpRequest request = exchange.getRequest().mutate() ServerHttpRequest request = exchange.getRequest().mutate()
.headers(httpHeaders -> httpHeaders.remove("X")) .headers(httpHeaders -> httpHeaders.remove("X"))
.headers(httpHeaders -> httpHeaders.add("hwy-req","1"))
.build(); .build();
// 2. 重写StripPrefix // 2. 重写StripPrefix

3
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/QualityDeliverListener.java

@ -86,11 +86,12 @@ public class QualityDeliverListener {
exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC), exchange = @Exchange(name = ReportConstants.REPORT_QUALITY_DELIVER_EXCHANGE, type = ExchangeTypes.TOPIC),
key = ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY key = ReportConstants.REPORT_QUALITY_DELIVER_ROUTINGKEY
)) ))
public void data(String msg) { public void data(String msg) throws InterruptedException {
log.info("配送明细基础表处理: {}", msg); log.info("配送明细基础表处理: {}", msg);
if (StrUtil.isEmpty(msg)) { if (StrUtil.isEmpty(msg)) {
return; return;
} }
Thread.sleep(1000*10);
ReportQualityDeliverDTO bean = JSONUtil.toBean(msg, ReportQualityDeliverDTO.class); ReportQualityDeliverDTO bean = JSONUtil.toBean(msg, ReportQualityDeliverDTO.class);
String data = bean.getData(); String data = bean.getData();
QualityDeliverEntity qualityDeliverEntity = JSONUtil.toBean(data, QualityDeliverEntity.class); QualityDeliverEntity qualityDeliverEntity = JSONUtil.toBean(data, QualityDeliverEntity.class);

2
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/ReservationPlanReportListener.java

@ -55,6 +55,8 @@ public class ReservationPlanReportListener {
)) ))
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void buildReport(String msg) { public void buildReport(String msg) {
log.info("预约计划生成明细报表: {}", msg); log.info("预约计划生成明细报表: {}", msg);
if (StrUtil.isEmpty(msg)) { if (StrUtil.isEmpty(msg)) {
return; return;

Loading…
Cancel
Save