Merge branch 'master' into eureka

eureka
tanghc 4 years ago
commit e4b493d58b
  1. 2
      sop-admin/sop-admin-server/src/main/resources/public/index.html
  2. 1
      sop-admin/sop-admin-server/src/main/resources/public/static/js/app.3f83e9e2.js
  3. 1
      sop-admin/sop-admin-server/src/main/resources/public/static/js/app.7297829f.js
  4. 4
      sop-admin/sop-admin-vue/.env.development
  5. 6
      sop-admin/sop-admin-vue/.env.production
  6. 12
      sop-admin/sop-admin-vue/README.md
  7. 2
      sop-admin/sop-admin-vue/src/utils/global.js
  8. 22
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/codec/MessageReaderFactory.java
  9. 20
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java
  10. 14
      sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/GlobalExceptionHandler.java
  11. 6
      sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/config/WebsiteConfig.java
  12. 3
      sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/controller/SandboxV2Controller.java
  13. 2
      sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/exception/LoginFailureException.java
  14. 5
      sop-website/sop-website-server/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>SOP Admin</title><link href=static/css/chunk-elementUI.81cf475c.css rel=stylesheet><link href=static/css/chunk-libs.3dfb7769.css rel=stylesheet><link href=static/css/app.6095bfbf.css rel=stylesheet></head><body><noscript><strong>We're sorry but SOP Admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>(function(e){function n(n){for(var r,c,a=n[0],f=n[1],i=n[2],d=0,h=[];d<a.length;d++)c=a[d],u[c]&&h.push(u[c][0]),u[c]=0;for(r in f)Object.prototype.hasOwnProperty.call(f,r)&&(e[r]=f[r]);l&&l(n);while(h.length)h.shift()();return o.push.apply(o,i||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],r=!0,c=1;c<t.length;c++){var a=t[c];0!==u[a]&&(r=!1)}r&&(o.splice(n--,1),e=f(f.s=t[0]))}return e}var r={},c={runtime:0},u={runtime:0},o=[];function a(e){return f.p+"static/js/"+({}[e]||e)+"."+{"chunk-25908fca":"f16786b7","chunk-2c1f2e8f":"f092c0a0","chunk-2d0d6219":"18813e69","chunk-2d2085ef":"91d75f3c","chunk-2d221c34":"20057287","chunk-2d238661":"5eefcb02","chunk-30c6c34f":"b288bbf5","chunk-4de1c2b6":"e74e3d03","chunk-73b2dcec":"60c5d8e9","chunk-9b31c83a":"494fc338","chunk-9f479afe":"2093f9d0","chunk-c3ce42fe":"9517b588"}[e]+".js"}function f(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.e=function(e){var n=[],t={"chunk-25908fca":1,"chunk-2c1f2e8f":1,"chunk-30c6c34f":1,"chunk-4de1c2b6":1,"chunk-73b2dcec":1,"chunk-9b31c83a":1,"chunk-c3ce42fe":1};c[e]?n.push(c[e]):0!==c[e]&&t[e]&&n.push(c[e]=new Promise(function(n,t){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-25908fca":"a66354ec","chunk-2c1f2e8f":"0314067f","chunk-2d0d6219":"31d6cfe0","chunk-2d2085ef":"31d6cfe0","chunk-2d221c34":"31d6cfe0","chunk-2d238661":"31d6cfe0","chunk-30c6c34f":"3b12267b","chunk-4de1c2b6":"a37cd815","chunk-73b2dcec":"ed391cc5","chunk-9b31c83a":"c4612b4a","chunk-9f479afe":"31d6cfe0","chunk-c3ce42fe":"6b789903"}[e]+".css",u=f.p+r,o=document.getElementsByTagName("link"),a=0;a<o.length;a++){var i=o[a],d=i.getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(d===r||d===u))return n()}var h=document.getElementsByTagName("style");for(a=0;a<h.length;a++){i=h[a],d=i.getAttribute("data-href");if(d===r||d===u)return n()}var l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.onload=n,l.onerror=function(n){var r=n&&n.target&&n.target.src||u,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.code="CSS_CHUNK_LOAD_FAILED",o.request=r,delete c[e],l.parentNode.removeChild(l),t(o)},l.href=u;var s=document.getElementsByTagName("head")[0];s.appendChild(l)}).then(function(){c[e]=0}));var r=u[e];if(0!==r)if(r)n.push(r[2]);else{var o=new Promise(function(n,t){r=u[e]=[n,t]});n.push(r[2]=o);var i,d=document.createElement("script");d.charset="utf-8",d.timeout=120,f.nc&&d.setAttribute("nonce",f.nc),d.src=a(e),i=function(n){d.onerror=d.onload=null,clearTimeout(h);var t=u[e];if(0!==t){if(t){var r=n&&("load"===n.type?"missing":n.type),c=n&&n.target&&n.target.src,o=new Error("Loading chunk "+e+" failed.\n("+r+": "+c+")");o.type=r,o.request=c,t[1](o)}u[e]=void 0}};var h=setTimeout(function(){i({type:"timeout",target:d})},12e4);d.onerror=d.onload=i,document.head.appendChild(d)}return Promise.all(n)},f.m=e,f.c=r,f.d=function(e,n,t){f.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},f.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,n){if(1&n&&(e=f(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)f.d(t,r,function(n){return e[n]}.bind(null,r));return t},f.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return f.d(n,"a",n),n},f.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},f.p="",f.oe=function(e){throw console.error(e),e};var i=window["webpackJsonp"]=window["webpackJsonp"]||[],d=i.push.bind(i);i.push=n,i=i.slice();for(var h=0;h<i.length;h++)n(i[h]);var l=d;t()})([]);</script><script src=static/js/chunk-elementUI.298ac98c.js></script><script src=static/js/chunk-libs.75deb05f.js></script><script src=static/js/app.3f83e9e2.js></script></body></html> <!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><link rel=icon href=favicon.ico><title>SOP Admin</title><link href=static/css/chunk-elementUI.81cf475c.css rel=stylesheet><link href=static/css/chunk-libs.3dfb7769.css rel=stylesheet><link href=static/css/app.6095bfbf.css rel=stylesheet></head><body><noscript><strong>We're sorry but SOP Admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>(function(e){function n(n){for(var r,c,a=n[0],f=n[1],i=n[2],d=0,h=[];d<a.length;d++)c=a[d],u[c]&&h.push(u[c][0]),u[c]=0;for(r in f)Object.prototype.hasOwnProperty.call(f,r)&&(e[r]=f[r]);l&&l(n);while(h.length)h.shift()();return o.push.apply(o,i||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],r=!0,c=1;c<t.length;c++){var a=t[c];0!==u[a]&&(r=!1)}r&&(o.splice(n--,1),e=f(f.s=t[0]))}return e}var r={},c={runtime:0},u={runtime:0},o=[];function a(e){return f.p+"static/js/"+({}[e]||e)+"."+{"chunk-25908fca":"f16786b7","chunk-2c1f2e8f":"f092c0a0","chunk-2d0d6219":"18813e69","chunk-2d2085ef":"91d75f3c","chunk-2d221c34":"20057287","chunk-2d238661":"5eefcb02","chunk-30c6c34f":"b288bbf5","chunk-4de1c2b6":"e74e3d03","chunk-73b2dcec":"60c5d8e9","chunk-9b31c83a":"494fc338","chunk-9f479afe":"2093f9d0","chunk-c3ce42fe":"9517b588"}[e]+".js"}function f(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.e=function(e){var n=[],t={"chunk-25908fca":1,"chunk-2c1f2e8f":1,"chunk-30c6c34f":1,"chunk-4de1c2b6":1,"chunk-73b2dcec":1,"chunk-9b31c83a":1,"chunk-c3ce42fe":1};c[e]?n.push(c[e]):0!==c[e]&&t[e]&&n.push(c[e]=new Promise(function(n,t){for(var r="static/css/"+({}[e]||e)+"."+{"chunk-25908fca":"a66354ec","chunk-2c1f2e8f":"0314067f","chunk-2d0d6219":"31d6cfe0","chunk-2d2085ef":"31d6cfe0","chunk-2d221c34":"31d6cfe0","chunk-2d238661":"31d6cfe0","chunk-30c6c34f":"3b12267b","chunk-4de1c2b6":"a37cd815","chunk-73b2dcec":"ed391cc5","chunk-9b31c83a":"c4612b4a","chunk-9f479afe":"31d6cfe0","chunk-c3ce42fe":"6b789903"}[e]+".css",u=f.p+r,o=document.getElementsByTagName("link"),a=0;a<o.length;a++){var i=o[a],d=i.getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(d===r||d===u))return n()}var h=document.getElementsByTagName("style");for(a=0;a<h.length;a++){i=h[a],d=i.getAttribute("data-href");if(d===r||d===u)return n()}var l=document.createElement("link");l.rel="stylesheet",l.type="text/css",l.onload=n,l.onerror=function(n){var r=n&&n.target&&n.target.src||u,o=new Error("Loading CSS chunk "+e+" failed.\n("+r+")");o.code="CSS_CHUNK_LOAD_FAILED",o.request=r,delete c[e],l.parentNode.removeChild(l),t(o)},l.href=u;var s=document.getElementsByTagName("head")[0];s.appendChild(l)}).then(function(){c[e]=0}));var r=u[e];if(0!==r)if(r)n.push(r[2]);else{var o=new Promise(function(n,t){r=u[e]=[n,t]});n.push(r[2]=o);var i,d=document.createElement("script");d.charset="utf-8",d.timeout=120,f.nc&&d.setAttribute("nonce",f.nc),d.src=a(e),i=function(n){d.onerror=d.onload=null,clearTimeout(h);var t=u[e];if(0!==t){if(t){var r=n&&("load"===n.type?"missing":n.type),c=n&&n.target&&n.target.src,o=new Error("Loading chunk "+e+" failed.\n("+r+": "+c+")");o.type=r,o.request=c,t[1](o)}u[e]=void 0}};var h=setTimeout(function(){i({type:"timeout",target:d})},12e4);d.onerror=d.onload=i,document.head.appendChild(d)}return Promise.all(n)},f.m=e,f.c=r,f.d=function(e,n,t){f.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},f.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,n){if(1&n&&(e=f(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)f.d(t,r,function(n){return e[n]}.bind(null,r));return t},f.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return f.d(n,"a",n),n},f.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},f.p="",f.oe=function(e){throw console.error(e),e};var i=window["webpackJsonp"]=window["webpackJsonp"]||[],d=i.push.bind(i);i.push=n,i=i.slice();for(var h=0;h<i.length;h++)n(i[h]);var l=d;t()})([]);</script><script src=static/js/chunk-elementUI.298ac98c.js></script><script src=static/js/chunk-libs.75deb05f.js></script><script src=static/js/app.7297829f.js></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,8 +1,8 @@
# just a flag # just a flag
ENV = 'development' ENV = 'development'
# base api # base api,末尾没有/
VUE_APP_BASE_API = 'http://localhost:8082/api' VUE_APP_BASE_API = 'http://localhost:8082'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable, # vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled. # to control whether the babel-plugin-dynamic-import-node plugin is enabled.

@ -1,6 +1,8 @@
# just a flag # just a flag
ENV = 'production' ENV = 'production'
# base api # base api,
VUE_APP_BASE_API = '/api' # 如果要前后端分离,这里填 http(s)://ip:port 末尾没有/
# 如:http://www.aaa.com, http://www.bbb.com:7777
VUE_APP_BASE_API = ''

@ -1,5 +1,7 @@
# SOP Admin 前端vue实现 # SOP Admin 前端vue实现
此工程基于前端脚手架:`https://github.com/PanJiaChen/vue-element-admin`
前提:先安装好npm,[npm安装教程](https://blog.csdn.net/zhangwenwu2/article/details/52778521) 前提:先安装好npm,[npm安装教程](https://blog.csdn.net/zhangwenwu2/article/details/52778521)
1. 启动服务端程序,运行`SopAdminServerApplication.java` 1. 启动服务端程序,运行`SopAdminServerApplication.java`
@ -14,5 +16,11 @@
如果想要把vue打包放到服务端,步骤如下: 如果想要把vue打包放到服务端,步骤如下:
- 执行`npm run build:prod`进行打包,结果在dest下 - 执行`npm run build:prod`进行打包,结果在`dist`下
- 打包完成后,把dest中的所有文件,放到`sop-admin-server/src/main/resources/public`下 - 打包完成后,把dest中的所有文件,放到`sop-admin-server/src/main/resources/public`下
## 前后端分离部署
- 修改`.env.production`,指定服务端地址
- 执行`npm run build:prod`进行打包,结果在`dist`下
- 把`dist`中的文件放到静态服务器上

@ -7,7 +7,7 @@ import { getToken, removeToken } from './auth'
// 创建axios实例 // 创建axios实例
const client = axios.create({ const client = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // api 的 base_url baseURL: process.env.VUE_APP_BASE_API + '/api', // api 的 base_url
timeout: 60000 // 请求超时时间,60秒 timeout: 60000 // 请求超时时间,60秒
}) })

@ -2,8 +2,11 @@ package com.gitee.sop.gatewaycommon.gateway.codec;
import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys; import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys;
import org.springframework.core.codec.AbstractDataBufferDecoder; import org.springframework.core.codec.AbstractDataBufferDecoder;
import org.springframework.core.codec.Decoder;
import org.springframework.http.codec.DecoderHttpMessageReader;
import org.springframework.http.codec.HttpMessageReader; import org.springframework.http.codec.HttpMessageReader;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.server.HandlerStrategies; import org.springframework.web.reactive.function.server.HandlerStrategies;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -43,4 +46,23 @@ public class MessageReaderFactory {
} }
return messageReaders; return messageReaders;
} }
public static void initMaxInMemorySize(ExchangeStrategies exchangeStrategies) {
// 修复返回大文本数据报org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144
String maxInMemorySizeValueStr = EnvironmentKeys.MAX_IN_MEMORY_SIZE.getValue();
int maxInMemorySizeValue = Integer.parseInt(maxInMemorySizeValueStr);
if (DEFAULT_SIZE == maxInMemorySizeValue) {
return;
}
for (HttpMessageReader<?> messageReader : exchangeStrategies.messageReaders()) {
if (messageReader instanceof DecoderHttpMessageReader) {
DecoderHttpMessageReader reader = (DecoderHttpMessageReader) messageReader;
Decoder decoder = reader.getDecoder();
if (decoder instanceof AbstractDataBufferDecoder) {
AbstractDataBufferDecoder dataBufferDecoder = (AbstractDataBufferDecoder)decoder;
dataBufferDecoder.setMaxInMemorySize(maxInMemorySizeValue);
}
}
}
}
} }

@ -2,10 +2,10 @@ package com.gitee.sop.gatewaycommon.gateway.filter;
import com.gitee.sop.gatewaycommon.bean.ApiContext; import com.gitee.sop.gatewaycommon.bean.ApiContext;
import com.gitee.sop.gatewaycommon.bean.SopConstants; import com.gitee.sop.gatewaycommon.bean.SopConstants;
import com.gitee.sop.gatewaycommon.gateway.codec.MessageReaderFactory;
import com.gitee.sop.gatewaycommon.result.ResultExecutor; import com.gitee.sop.gatewaycommon.result.ResultExecutor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.filter.NettyWriteResponseFilter; import org.springframework.cloud.gateway.filter.NettyWriteResponseFilter;
@ -13,16 +13,12 @@ import org.springframework.cloud.gateway.filter.factory.rewrite.CachedBodyOutput
import org.springframework.cloud.gateway.support.BodyInserterContext; import org.springframework.cloud.gateway.support.BodyInserterContext;
import org.springframework.cloud.gateway.support.DefaultClientResponse; import org.springframework.cloud.gateway.support.DefaultClientResponse;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.codec.AbstractDataBufferDecoder;
import org.springframework.core.codec.Decoder;
import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseCookie;
import org.springframework.http.client.reactive.ClientHttpResponse; import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.http.codec.DecoderHttpMessageReader;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.server.reactive.ServerHttpResponseDecorator; import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserter;
@ -40,9 +36,6 @@ import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.O
*/ */
public class GatewayModifyResponseGatewayFilter implements GlobalFilter, Ordered { public class GatewayModifyResponseGatewayFilter implements GlobalFilter, Ordered {
@Value("${spring.codec.max-in-memory-size:262144}")
private int maxInMemorySize;
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
@ -107,16 +100,7 @@ public class GatewayModifyResponseGatewayFilter implements GlobalFilter, Ordered
private ExchangeStrategies getExchangeStrategies() { private ExchangeStrategies getExchangeStrategies() {
ExchangeStrategies exchangeStrategies = ExchangeStrategies.withDefaults(); ExchangeStrategies exchangeStrategies = ExchangeStrategies.withDefaults();
// 修复返回大文本数据报org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144 // 修复返回大文本数据报org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144
for (HttpMessageReader<?> messageReader : exchangeStrategies.messageReaders()) { MessageReaderFactory.initMaxInMemorySize(exchangeStrategies);
if (messageReader instanceof DecoderHttpMessageReader) {
DecoderHttpMessageReader reader = (DecoderHttpMessageReader) messageReader;
Decoder decoder = reader.getDecoder();
if (decoder instanceof AbstractDataBufferDecoder) {
AbstractDataBufferDecoder dataBufferDecoder = (AbstractDataBufferDecoder)decoder;
dataBufferDecoder.setMaxInMemorySize(maxInMemorySize);
}
}
}
return exchangeStrategies; return exchangeStrategies;
} }

@ -22,6 +22,7 @@ import java.nio.charset.StandardCharsets;
@Slf4j @Slf4j
public class GlobalExceptionHandler { public class GlobalExceptionHandler {
/** /**
* 与网关约定好的状态码表示业务出错 * 与网关约定好的状态码表示业务出错
*/ */
@ -33,10 +34,15 @@ public class GlobalExceptionHandler {
private static final int SYSTEM_ERROR_CODE = 5050; private static final int SYSTEM_ERROR_CODE = 5050;
/** /**
* 返回错误信息headerName * header中的错误code
*/ */
private static final String X_SERVICE_ERROR_HEADER_NAME = "x-service-error-code"; private static final String X_SERVICE_ERROR_HEADER_NAME = "x-service-error-code";
/**
* header中的错误信息
*/
private static final String X_SERVICE_ERROR_MESSAGE = "x-service-error-message";
/** /**
* 捕获手动抛出的异常 * 捕获手动抛出的异常
* *
@ -63,7 +69,6 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@ResponseBody @ResponseBody
public Object exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) { public Object exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) {
response.addHeader(X_SERVICE_ERROR_HEADER_NAME, String.valueOf(SYSTEM_ERROR_CODE));
log.error("系统错误", exception); log.error("系统错误", exception);
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append(exception.getMessage()); msg.append(exception.getMessage());
@ -74,7 +79,10 @@ public class GlobalExceptionHandler {
StackTraceElement stackTraceElement = stackTrace[i]; StackTraceElement stackTraceElement = stackTrace[i];
msg.append("\n at ").append(stackTraceElement.toString()); msg.append("\n at ").append(stackTraceElement.toString());
} }
response.setHeader("x-service-error-message", UriUtils.encode(msg.toString(), StandardCharsets.UTF_8)); // 需要设置两个值,这样网关会收到错误信息
// 并且会统计到监控当中
response.setHeader(X_SERVICE_ERROR_HEADER_NAME, String.valueOf(SYSTEM_ERROR_CODE));
response.setHeader(X_SERVICE_ERROR_MESSAGE, UriUtils.encode(msg.toString(), StandardCharsets.UTF_8));
return this.processError(request, response, new ServiceException("系统繁忙")); return this.processError(request, response, new ServiceException("系统繁忙"));
} }

@ -8,13 +8,10 @@ import com.gitee.sop.gatewaycommon.manager.EnvironmentContext;
import com.gitee.sop.gatewaycommon.route.RegistryListener; import com.gitee.sop.gatewaycommon.route.RegistryListener;
import com.gitee.sop.gatewaycommon.route.ServiceListener; import com.gitee.sop.gatewaycommon.route.ServiceListener;
import com.gitee.sop.websiteserver.listener.ServiceDocListener; import com.gitee.sop.websiteserver.listener.ServiceDocListener;
import com.gitee.sop.websiteserver.manager.DocManager;
import com.gitee.sop.websiteserver.service.impl.EurekaServerService; import com.gitee.sop.websiteserver.service.impl.EurekaServerService;
import com.gitee.sop.websiteserver.service.impl.NacosServerService; import com.gitee.sop.websiteserver.service.impl.NacosServerService;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
@ -36,9 +33,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration @Configuration
public class WebsiteConfig implements WebMvcConfigurer, EnvironmentAware, ApplicationContextAware { public class WebsiteConfig implements WebMvcConfigurer, EnvironmentAware, ApplicationContextAware {
@Autowired
DocManager docManager;
@Autowired @Autowired
private RegistryListener registryListener; private RegistryListener registryListener;

@ -103,7 +103,8 @@ public class SandboxV2Controller {
try { try {
sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8"); sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8");
} catch (AlipayApiException e) { } catch (AlipayApiException e) {
throw new RuntimeException("构建签名失败"); log.error("构建签名失败", e);
throw new RuntimeException("构建签名失败", e);
} }
params.put("sign", sign); params.put("sign", sign);

@ -3,7 +3,7 @@ package com.gitee.sop.websiteserver.exception;
/** /**
* @author tanghc * @author tanghc
*/ */
public class LoginFailureException extends RuntimeException implements ExceptionCode{ public class LoginFailureException extends RuntimeException implements ExceptionCode {
@Override @Override
public ErrorCode getCode() { public ErrorCode getCode() {
return ErrorCode.LOGIN_FAIL; return ErrorCode.LOGIN_FAIL;

@ -14,9 +14,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.DigestUtils;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -220,6 +218,7 @@ public class SwaggerDocParser implements DocParser {
JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref); JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref);
String className = responseObject.getString("title"); String className = responseObject.getString("title");
JSONObject extProperties = docRoot.getJSONObject(className); JSONObject extProperties = docRoot.getJSONObject(className);
JSONArray requiredProperties = responseObject.getJSONArray("required");
JSONObject properties = responseObject.getJSONObject("properties"); JSONObject properties = responseObject.getJSONObject("properties");
List<DocParameter> docParameterList = new ArrayList<>(); List<DocParameter> docParameterList = new ArrayList<>();
if (properties == null) { if (properties == null) {
@ -236,6 +235,8 @@ public class SwaggerDocParser implements DocParser {
JSONObject fieldInfo = properties.getJSONObject(fieldName); JSONObject fieldInfo = properties.getJSONObject(fieldName);
DocParameter docParameter = fieldInfo.toJavaObject(DocParameter.class); DocParameter docParameter = fieldInfo.toJavaObject(DocParameter.class);
docParameter.setName(fieldName); docParameter.setName(fieldName);
docParameter.setRequired(
!CollectionUtils.isEmpty(requiredProperties) && requiredProperties.contains(fieldName));
if (extProperties != null) { if (extProperties != null) {
JSONObject prop = extProperties.getJSONObject(fieldName); JSONObject prop = extProperties.getJSONObject(fieldName);
if (prop != null) { if (prop != null) {

Loading…
Cancel
Save