Commit f966b5553cf300b944848cd5d8b929a713333d24
1 parent
e46dab0f
一些错误修改
Showing
10 changed files
with
17 additions
and
31 deletions
gateway-business/src/main/java/com/diligrp/xtrade/business/XtradeGatewayApplication.java
gateway-core/src/main/java/com/diligrp/xtrade/core/common/utils/ResponseUtils.java
... | ... | @@ -18,7 +18,7 @@ public class ResponseUtils { |
18 | 18 | |
19 | 19 | |
20 | 20 | public static Mono<Void> writeForbidden(ServerHttpResponse response){ |
21 | - Message<Object> message = Message.builder().failure( | |
21 | + Message message = Message.failure( | |
22 | 22 | HttpStatus.FORBIDDEN.value(),HttpStatus.FORBIDDEN.toString()); |
23 | 23 | return writeResponse(response,message); |
24 | 24 | } | ... | ... |
gateway-core/src/main/java/com/diligrp/xtrade/core/filters/global/AuthGlobalFilter.java
... | ... | @@ -36,22 +36,20 @@ public class AuthGlobalFilter implements GlobalFilter, Ordered { |
36 | 36 | //排除在外的Uri跳过权限 |
37 | 37 | if (apiManager.isExcludePathMatch(originalUri)) { |
38 | 38 | return chain.filter(exchange); |
39 | - // throw new RuntimeException("异常测试"); | |
40 | 39 | } |
41 | 40 | exchange.getAttributes().put(ServerWebExchangeUtils.ORIGINAL_RESPONSE_CONTENT_TYPE_ATTR, MediaType.APPLICATION_JSON_VALUE); |
42 | 41 | return ResponseUtils.writeForbidden(response); |
43 | 42 | } |
44 | 43 | |
44 | + @Override | |
45 | + public int getOrder() { | |
46 | + return GatewayConst.AUTH_FILTER_ORDER; | |
47 | + } | |
48 | + | |
45 | 49 | private static String getOriginalUri(ServerWebExchange exchange) { |
46 | 50 | LinkedHashSet<URI> uris = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR); |
47 | 51 | return Optional.ofNullable(uris) |
48 | 52 | .flatMap(us -> us.stream().findFirst().map(URI::getRawPath)) |
49 | 53 | .orElse(exchange.getRequest().getURI().getRawPath()); |
50 | 54 | } |
51 | - | |
52 | - @Override | |
53 | - public int getOrder() { | |
54 | - return GatewayConst.AUTH_FILTER_ORDER; | |
55 | - } | |
56 | - | |
57 | 55 | } | ... | ... |
gateway-core/src/main/java/com/diligrp/xtrade/core/filters/global/CacheRequestBodyGlobalFilter.java
1 | 1 | package com.diligrp.xtrade.core.filters.global; |
2 | 2 | |
3 | 3 | import com.diligrp.xtrade.core.common.constant.GatewayConst; |
4 | +import com.diligrp.xtrade.shared.util.JsonUtils; | |
4 | 5 | import org.apache.commons.lang3.StringUtils; |
5 | 6 | import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
6 | 7 | import org.springframework.cloud.gateway.filter.GlobalFilter; |
... | ... | @@ -40,7 +41,7 @@ public class CacheRequestBodyGlobalFilter implements GlobalFilter, Ordered { |
40 | 41 | @Override |
41 | 42 | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
42 | 43 | String contentType = exchange.getRequest().getHeaders().getFirst(HttpHeaders.CONTENT_TYPE); |
43 | - if (StringUtils.isNotBlank(contentType) && contentType.startsWith("multipart")) { | |
44 | + if (StringUtils.isNotBlank(contentType) && contentType.contains("multipart")) { | |
44 | 45 | return chain.filter(exchange); |
45 | 46 | } |
46 | 47 | ServerRequest serverRequest = ServerRequest.create(exchange, | ... | ... |
gateway-core/src/main/java/com/diligrp/xtrade/core/filters/web/FacadeWebFilter.java
... | ... | @@ -63,29 +63,29 @@ public class FacadeWebFilter implements WebFilter { |
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | - private static Message<Object> handleException(Throwable ex) { | |
66 | + private static Message handleException(Throwable ex) { | |
67 | 67 | if (ex instanceof GatewayDispatchException) { |
68 | 68 | GatewayDispatchException dispatchEx = (GatewayDispatchException) ex; |
69 | 69 | if (dispatchEx.getCause() != null) { |
70 | 70 | return handleException(dispatchEx.getCause()); |
71 | 71 | } else { |
72 | - return Message.builder().failure( | |
72 | + return Message.failure( | |
73 | 73 | ErrorCode.UNKNOWN_ERROR.getCode(), ErrorCode.UNKNOWN_ERROR.getName()); |
74 | 74 | } |
75 | 75 | } else if (ex instanceof ResponseStatusException) { |
76 | 76 | ResponseStatusException statusException = (ResponseStatusException) ex; |
77 | 77 | log.warn("response status error:{}", statusException.getMessage()); |
78 | - return Message.builder().failure(statusException.getStatus().value(), ex.getMessage()); | |
78 | + return Message.failure(statusException.getStatus().value(), ex.getMessage()); | |
79 | 79 | } else if (ex instanceof GatewayParamNotValidException) { |
80 | - return Message.builder().failure( | |
80 | + return Message.failure( | |
81 | 81 | ErrorCode.ILLEGAL_PARAMS.getCode(), ex.getMessage()); |
82 | 82 | } else if (ex instanceof TimeoutException){ |
83 | 83 | log.error("api处理超时:", ex); |
84 | - return Message.builder().failure( | |
84 | + return Message.failure( | |
85 | 85 | ErrorCode.UNKNOWN_ERROR.getCode(), "请求超时"); |
86 | 86 | } else { |
87 | 87 | log.error("unknown error:", ex); |
88 | - return Message.builder().failure( | |
88 | + return Message.failure( | |
89 | 89 | ErrorCode.UNKNOWN_ERROR.getCode(), ErrorCode.UNKNOWN_ERROR.getName()); |
90 | 90 | } |
91 | 91 | } | ... | ... |
gateway-core/src/main/java/com/diligrp/xtrade/core/repository/entity/GatewayConfig.java
... | ... | @@ -37,16 +37,6 @@ public class GatewayConfig extends BaseDo { |
37 | 37 | this.url = url; |
38 | 38 | } |
39 | 39 | |
40 | - @Override | |
41 | - public Integer getIsDel() { | |
42 | - return isDel; | |
43 | - } | |
44 | - | |
45 | - @Override | |
46 | - public void setIsDel(Integer isDel) { | |
47 | - this.isDel = isDel; | |
48 | - } | |
49 | - | |
50 | 40 | public String getDescription() { |
51 | 41 | return description; |
52 | 42 | } | ... | ... |
gateway-core/src/main/java/com/diligrp/xtrade/core/support/dispatch/MappingRegister.java
... | ... | @@ -50,7 +50,6 @@ public class MappingRegister implements ApplicationListener<ContextRefreshedEven |
50 | 50 | .addScanners(new MethodAnnotationsScanner()) |
51 | 51 | .addScanners(new FieldAnnotationsScanner())); |
52 | 52 | try { |
53 | - | |
54 | 53 | Set<Method> methodMappings = reflections.getMethodsAnnotatedWith(DispatchMapping.class); |
55 | 54 | for (Method method : methodMappings) { |
56 | 55 | //只扫描参数为DispatchContext的方法 | ... | ... |
gateway-core/src/main/java/com/diligrp/xtrade/core/support/dispatch/RequestDispatcher.java
... | ... | @@ -68,7 +68,7 @@ public class RequestDispatcher { |
68 | 68 | } |
69 | 69 | //分发逻辑 |
70 | 70 | Object resultData = this.beginDispatch(matchUri, paramsJson, exchange); |
71 | - return Message.builder().success(resultData); | |
71 | + return Message.success(resultData); | |
72 | 72 | } catch (Throwable e) { |
73 | 73 | throw new GatewayDispatchException("dispatch method error", e); |
74 | 74 | } | ... | ... |
gateway-core/src/main/resources/mapper/AttrConfigDao.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
3 | -<mapper namespace="com.diligrp.xtrade.gateway.repository.dao.AttrConfigDao"> | |
3 | +<mapper namespace="com.diligrp.xtrade.core.repository.dao.AttrConfigDao"> | |
4 | 4 | <resultMap id="Base_Result_Map" type="com.diligrp.xtrade.core.repository.entity.GatewayAttrConfig"> |
5 | 5 | <id property="id" column="id"/> |
6 | 6 | <result property="serviceId" column="service_id"/> |
... | ... | @@ -9,7 +9,6 @@ |
9 | 9 | <result property="attrArgs" column="attr_args"/> |
10 | 10 | <result property="description" column="description"/> |
11 | 11 | <result property="sortOrder" column="sort_order"/> |
12 | - <result property="isDel" column="is_del"/> | |
13 | 12 | <result property="modifiedTime" column="modified_time"/> |
14 | 13 | <result property="createdTime" column="created_time"/> |
15 | 14 | </resultMap> | ... | ... |
gateway-core/src/main/resources/mapper/RouteDao.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
3 | -<mapper namespace="com.diligrp.xtrade.gateway.repository.dao.RouteDao"> | |
3 | +<mapper namespace="com.diligrp.xtrade.core.repository.dao.RouteDao"> | |
4 | 4 | <resultMap id="Base_Result_Map" type="com.diligrp.xtrade.core.repository.entity.GatewayConfig"> |
5 | 5 | <id property="id" column="id"/> |
6 | 6 | <result property="url" column="url"/> | ... | ... |