mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、gateway网关增加请求大小限制配置(10M)、增加accesslog过滤器对部分过大请求的打印内容减少;2、数据集增改organid和数据源统一、ureport对象floatimages补充;3、报表预览内置数据源处理预实现、配置增加;
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.cf.imes.gateway.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 网关配置
|
||||
*
|
||||
* @author 晨丰科技
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "chenfeng.gateway")
|
||||
@Data
|
||||
public class CfGatewayProperties {
|
||||
|
||||
|
||||
/**
|
||||
* 需要忽略打印requestBody和responseBody的请求地址列表
|
||||
*/
|
||||
private Set<String> accessLogIgnoreUrls = Collections.emptySet();
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.cf.imes.gateway.filter.logging;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.gateway.config.CfGatewayProperties;
|
||||
import com.cf.imes.gateway.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.gateway.util.WebFrameworkUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
@@ -60,6 +62,22 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
||||
@Resource
|
||||
private CodecConfigurer codecConfigurer;
|
||||
|
||||
@Resource
|
||||
private CfGatewayProperties cfGatewayProperties;
|
||||
|
||||
/**
|
||||
* 是否需要打印请求体和响应体
|
||||
*
|
||||
* @param requestUrl 请求路径
|
||||
* @return
|
||||
*/
|
||||
protected boolean shouldLogParamAndBody(String requestUrl) {
|
||||
if (CollUtil.isEmpty(cfGatewayProperties.getAccessLogIgnoreUrls())) {
|
||||
return true;
|
||||
}
|
||||
return !cfGatewayProperties.getAccessLogIgnoreUrls().stream().anyMatch(excludeUrl -> requestUrl.contains(excludeUrl));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印日志
|
||||
*
|
||||
@@ -78,14 +96,20 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
|
||||
values.put("userType", gatewayLog.getUserType());
|
||||
values.put("routeId", gatewayLog.getRoute() != null ? gatewayLog.getRoute().getId() : null);
|
||||
values.put("schema", gatewayLog.getSchema());
|
||||
values.put("requestUrl", gatewayLog.getRequestUrl());
|
||||
String requestUrl = gatewayLog.getRequestUrl();
|
||||
values.put("requestUrl", requestUrl);
|
||||
values.put("queryParams", gatewayLog.getQueryParams().toSingleValueMap());
|
||||
values.put("requestBody", JsonUtils.isJson(gatewayLog.getRequestBody()) ? // 保证 body 的展示好看
|
||||
JSONUtil.parse(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
|
||||
|
||||
values.put("requestHeaders", JsonUtils.toJsonString(gatewayLog.getRequestHeaders().toSingleValueMap()));
|
||||
values.put("userIp", gatewayLog.getUserIp());
|
||||
values.put("responseBody", JsonUtils.isJson(gatewayLog.getResponseBody()) ? // 保证 body 的展示好看
|
||||
JSONUtil.parse(gatewayLog.getResponseBody()) : gatewayLog.getResponseBody());
|
||||
// 过滤特定大请求不打印日志
|
||||
if (shouldLogParamAndBody(requestUrl)) {
|
||||
values.put("requestBody", JsonUtils.isJson(gatewayLog.getRequestBody()) ? // 保证 body 的展示好看
|
||||
JSONUtil.parse(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
|
||||
|
||||
values.put("responseBody", JsonUtils.isJson(gatewayLog.getResponseBody()) ? // 保证 body 的展示好看
|
||||
JSONUtil.parse(gatewayLog.getResponseBody()) : gatewayLog.getResponseBody());
|
||||
}
|
||||
values.put("responseHeaders", gatewayLog.getResponseHeaders() != null ?
|
||||
JsonUtils.toJsonString(gatewayLog.getResponseHeaders().toSingleValueMap()) : null);
|
||||
values.put("httpStatus", gatewayLog.getHttpStatus());
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
|
||||
codec:
|
||||
# getway请求大小限制10M:1024 * 1024 * 10
|
||||
max-in-memory-size: 10485760
|
||||
|
||||
cloud:
|
||||
# Spring Cloud Gateway 配置项,对应 GatewayProperties 类
|
||||
@@ -99,3 +102,9 @@ knife4j:
|
||||
- name: report-server
|
||||
service-name: report-server
|
||||
url: /admin-api/report/v3/api-docs
|
||||
|
||||
chenfeng:
|
||||
gateway:
|
||||
access-log-ignore-urls:
|
||||
- /report/template/
|
||||
- /system/captcha/get
|
||||
Reference in New Issue
Block a user