|
@ -39,40 +39,52 @@ public class PostFilter extends ZuulFilter {
|
|
|
@Override
|
|
|
public Object run() {
|
|
|
RequestContext ctx = RequestContext.getCurrentContext();
|
|
|
logger.info("进入post过滤器");
|
|
|
HttpServletRequest request = ctx.getRequest();
|
|
|
String url = request.getRequestURI();
|
|
|
if (url.contains("/excelControl")){
|
|
|
return true;
|
|
|
}
|
|
|
InputStream stream = RequestContext.getCurrentContext().getResponseDataStream();
|
|
|
try {
|
|
|
byte[] bytes;
|
|
|
if(RequestContext.getCurrentContext().getResponseGZipped()){
|
|
|
GZIPInputStream gzipInputStream = null;
|
|
|
gzipInputStream = new GZIPInputStream(stream);
|
|
|
bytes = StreamUtils.copyToByteArray(gzipInputStream);
|
|
|
}else {
|
|
|
bytes = StreamUtils.copyToByteArray(stream);
|
|
|
}
|
|
|
String body = new String(bytes,"UTF8");
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("status","200");
|
|
|
object.put("data", AesEncryptUtils.encrypt(body));
|
|
|
if (!(url.contains("/open/noLogin/notify")||
|
|
|
url.contains("/open/noLogin/ylzReceiveNotify")||
|
|
|
url.contains("/open/noLogin/receiveNotify")||
|
|
|
url.contains("/open/noLogin/getSFExpressInfoNew")||
|
|
|
url.contains("/open/noLogin/sfroutepushservice")||
|
|
|
url.contains("/open/noLogin/ylzSettleRecord")||
|
|
|
url.contains("/weixin")||url.contains("/oauth/getSsoPublicKey"))){
|
|
|
RequestContext.getCurrentContext().setResponseBody(object.toJSONString());
|
|
|
}else {
|
|
|
RequestContext.getCurrentContext().setResponseBody(body);
|
|
|
logger.info("进入post过滤器"+ctx.getResponseStatusCode()+"==="+ctx.getRequest().getServletPath()+"==="+ctx.getResponse().getStatus()+"==");
|
|
|
if (ctx.getRequest().getServletPath().contains("/hospital/")){
|
|
|
if (ctx.getResponse().getStatus()==500){
|
|
|
ctx.setSendZuulResponse(false);
|
|
|
ctx.setThrowable(null);
|
|
|
ctx.setResponseStatusCode(10111);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
logger.info(ctx.getResponseBody()+"");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
if (ctx.getResponse().getStatus()!=500){
|
|
|
HttpServletRequest request = ctx.getRequest();
|
|
|
String url = request.getRequestURI();
|
|
|
if (url.contains("/excelControl")){
|
|
|
return true;
|
|
|
}
|
|
|
InputStream stream = RequestContext.getCurrentContext().getResponseDataStream();
|
|
|
try {
|
|
|
byte[] bytes;
|
|
|
if(RequestContext.getCurrentContext().getResponseGZipped()){
|
|
|
GZIPInputStream gzipInputStream = null;
|
|
|
gzipInputStream = new GZIPInputStream(stream);
|
|
|
bytes = StreamUtils.copyToByteArray(gzipInputStream);
|
|
|
}else {
|
|
|
bytes = StreamUtils.copyToByteArray(stream);
|
|
|
}
|
|
|
String body = new String(bytes,"UTF8");
|
|
|
logger.info("body"+body);
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("status","200");
|
|
|
object.put("data", AesEncryptUtils.encrypt(body));
|
|
|
if (!(url.contains("/open/noLogin/notify")||
|
|
|
url.contains("/open/noLogin/ylzReceiveNotify")||
|
|
|
url.contains("/open/noLogin/receiveNotify")||
|
|
|
url.contains("/open/noLogin/getSFExpressInfoNew")||
|
|
|
url.contains("/open/noLogin/sfroutepushservice")||
|
|
|
url.contains("/open/noLogin/ylzSettleRecord")||
|
|
|
url.contains("/weixin")||url.contains("/oauth/getSsoPublicKey"))){
|
|
|
RequestContext.getCurrentContext().setResponseBody(object.toJSONString());
|
|
|
}else {
|
|
|
RequestContext.getCurrentContext().setResponseBody(body);
|
|
|
}
|
|
|
logger.info(ctx.getResponseBody()+"");
|
|
|
} catch (Exception e) {
|
|
|
logger.info("");
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
|