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
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.cf.imes.module.report.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 报表配置
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/9/26 16:41
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties("chenfeng.report")
|
||||
@Data
|
||||
public class CfReportProperties {
|
||||
/**
|
||||
* 多租户表名称列表
|
||||
*/
|
||||
private Set<String> tenantTableNames;
|
||||
}
|
||||
+1
-14
@@ -22,12 +22,6 @@ public interface ReportDatasetService {
|
||||
*/
|
||||
Long createDataset(@Valid ReportDatasetSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 批量创建报表数据集
|
||||
* @param createReqVOList
|
||||
*/
|
||||
void batchCreateDataset(@Valid List<ReportDatasetSaveReqVO> createReqVOList);
|
||||
|
||||
/**
|
||||
* 更新报表数据集
|
||||
*
|
||||
@@ -35,13 +29,6 @@ public interface ReportDatasetService {
|
||||
*/
|
||||
void updateDataset(@Valid ReportDatasetSaveReqVO updateReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新报表数据集
|
||||
* @param createReqVOList
|
||||
*/
|
||||
void batchUpdateDataset(@Valid List<ReportDatasetSaveReqVO> createReqVOList);
|
||||
|
||||
/**
|
||||
* 删除报表数据集
|
||||
*
|
||||
@@ -60,7 +47,7 @@ public interface ReportDatasetService {
|
||||
/**
|
||||
* 获得报表数据集分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @param reqVO 分页查询
|
||||
* @return 报表数据集分页
|
||||
*/
|
||||
List<ReportDatasetDO> getDatasetList(ReportDatasetReqVO reqVO);
|
||||
|
||||
+17
-22
@@ -1,6 +1,5 @@
|
||||
package com.cf.imes.module.report.service.dataset;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@@ -41,41 +40,29 @@ public class ReportDatasetServiceImpl implements ReportDatasetService {
|
||||
@Override
|
||||
public Long createDataset(ReportDatasetSaveReqVO createReqVO) {
|
||||
// 校验内置模板操作权限
|
||||
validateSystemDataset(createReqVO.getDatasourceId());
|
||||
ReportDatasourceDO reportDatasourceDO = validateSystemDataset(createReqVO.getDatasourceId());
|
||||
// 插入
|
||||
ReportDatasetDO dataset = BeanUtils.toBean(createReqVO, ReportDatasetDO.class);
|
||||
// 数据集机构id和数据源统一
|
||||
dataset.setOrganId(reportDatasourceDO.getOrganId());
|
||||
datasetMapper.insert(dataset);
|
||||
// 返回
|
||||
return dataset.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchCreateDataset(List<ReportDatasetSaveReqVO> createReqVOList) {
|
||||
List<ReportDatasetDO> reportDatasetDOS = BeanUtils.toBean(createReqVOList, ReportDatasetDO.class);
|
||||
if (CollUtil.isNotEmpty(reportDatasetDOS)) {
|
||||
datasetMapper.insertBatch(reportDatasetDOS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataset(ReportDatasetSaveReqVO updateReqVO) {
|
||||
// 校验内置模板操作权限
|
||||
validateSystemDataset(updateReqVO.getDatasourceId());
|
||||
ReportDatasourceDO reportDatasourceDO = validateSystemDataset(updateReqVO.getDatasourceId());
|
||||
// 校验存在
|
||||
validateDatasetExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReportDatasetDO updateObj = BeanUtils.toBean(updateReqVO, ReportDatasetDO.class);
|
||||
// 数据集机构id和数据源统一
|
||||
updateObj.setOrganId(reportDatasourceDO.getOrganId());
|
||||
datasetMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchUpdateDataset(List<ReportDatasetSaveReqVO> createReqVOList) {
|
||||
List<ReportDatasetDO> reportDatasetDOS = BeanUtils.toBean(createReqVOList, ReportDatasetDO.class);
|
||||
if (CollUtil.isNotEmpty(reportDatasetDOS)) {
|
||||
datasetMapper.updateBatch(reportDatasetDOS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDataset(Long id) {
|
||||
// 校验存在
|
||||
@@ -100,15 +87,23 @@ public class ReportDatasetServiceImpl implements ReportDatasetService {
|
||||
*
|
||||
* @param datasourceId 数据源id
|
||||
*/
|
||||
private void validateSystemDataset(Long datasourceId) {
|
||||
ReportDatasourceDO reportDatasourceDO = reportDatasourceMapper.selectNormalDatasourceById(datasourceId, SecurityFrameworkUtils.getUserOrganId());
|
||||
private ReportDatasourceDO validateSystemDataset(Long datasourceId) {
|
||||
ReportDatasourceDO reportDatasourceDO = null;
|
||||
boolean superAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
||||
// 超管查所有,其他人查机构下
|
||||
if (superAdmin) {
|
||||
reportDatasourceDO = reportDatasourceMapper.selectById(datasourceId);
|
||||
} else {
|
||||
reportDatasourceDO = reportDatasourceMapper.selectNormalDatasourceById(datasourceId, SecurityFrameworkUtils.getUserOrganId());
|
||||
}
|
||||
if (ObjectUtil.isNull(reportDatasourceDO)) {
|
||||
throw exception(DATASOURCE_NOT_EXISTS);
|
||||
}
|
||||
// 非超管不能操作内置模板
|
||||
if (ReportTemplateTypeEnum.SYSTEM.equals(reportDatasourceDO.getBuildinType()) && Boolean.FALSE.equals(SecurityFrameworkUtils.isSuperAdmin())) {
|
||||
if (ReportTemplateTypeEnum.SYSTEM.equals(reportDatasourceDO.getBuildinType()) && Boolean.FALSE.equals(superAdmin)) {
|
||||
throw exception(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
}
|
||||
return reportDatasourceDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
@@ -35,6 +35,7 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.report.api.template.dto.ReportTemplateGenerateReqDTO;
|
||||
import com.cf.imes.module.report.config.CfReportProperties;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateReqVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateRespVO;
|
||||
import com.cf.imes.module.report.controller.admin.template.vo.ReportTemplateSaveReqVO;
|
||||
@@ -89,6 +90,9 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
|
||||
private static final String UTF8_CHARSET = CharsetUtil.UTF_8;
|
||||
|
||||
@Resource
|
||||
private CfReportProperties cfReportProperties;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ReportTemplateRespVO createReportTemplate(ReportTemplateSaveReqVO createReqVO) {
|
||||
@@ -353,6 +357,12 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
ReportRender reportRender = new ReportRender();
|
||||
ReportDefinition reportDefinition = getReportDefinition(reportRender, params);
|
||||
Map<String, Object> parameters = params.getQuery();
|
||||
// imes多租户业务表表名列表
|
||||
Set<String> tenantTableNames = cfReportProperties.getTenantTableNames();
|
||||
if (CollUtil.isNotEmpty(tenantTableNames)) {
|
||||
parameters.put("tenantTableNames", cfReportProperties.getTenantTableNames());
|
||||
parameters.put("organId", SecurityFrameworkUtils.getUserOrganId());
|
||||
}
|
||||
Report report = reportRender.render(reportDefinition, parameters);
|
||||
return htmlProducer.produce(reportDefinition, report);
|
||||
}
|
||||
|
||||
@@ -105,4 +105,20 @@ chenfeng:
|
||||
ignore-tables:
|
||||
encrypt:
|
||||
enable: false
|
||||
publicKey: cfimes
|
||||
publicKey: cfimes
|
||||
tenant-table-names:
|
||||
- system_dept
|
||||
- system_user
|
||||
- system_organization
|
||||
- order_body
|
||||
- order_goods
|
||||
- order_group
|
||||
- order_item
|
||||
- order_parts
|
||||
- order_plan
|
||||
- order_plan_item
|
||||
- order_plate
|
||||
- order_prepackaged
|
||||
- order_remain_plate
|
||||
- orders
|
||||
- plate
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user