mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
1、统一抛出ServiceException带占位符的填充方式,不再使用ServiceExceptionUtils;2、新增System服务ErrorCode的国际化;3、Webcad异步导入移除分布式锁,导入解析事务完善;
This commit is contained in:
+4
-4
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.report.service.dataset;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@@ -18,7 +19,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_NOT_EXISTS;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASOURCE_NOT_EXISTS;
|
||||
@@ -82,7 +82,7 @@ public class ReportDatasetServiceImpl implements ReportDatasetService {
|
||||
private ReportDatasetDO validateDatasetExists(Long id) {
|
||||
ReportDatasetDO reportDatasetDO = datasetMapper.selectById(id);
|
||||
if (ObjectUtil.isNull(reportDatasetDO)) {
|
||||
throw exception(DATASET_NOT_EXISTS);
|
||||
throw new ServiceException(DATASET_NOT_EXISTS);
|
||||
} else {
|
||||
return reportDatasetDO;
|
||||
}
|
||||
@@ -103,11 +103,11 @@ public class ReportDatasetServiceImpl implements ReportDatasetService {
|
||||
reportDatasourceDO = reportDatasourceMapper.selectNormalDatasourceById(datasourceId, SecurityFrameworkUtils.getUserOrganId());
|
||||
}
|
||||
if (ObjectUtil.isNull(reportDatasourceDO)) {
|
||||
throw exception(DATASOURCE_NOT_EXISTS);
|
||||
throw new ServiceException(DATASOURCE_NOT_EXISTS);
|
||||
}
|
||||
// 非超管不能操作内置模板
|
||||
if (ReportTemplateTypeEnum.SYSTEM.equals(reportDatasourceDO.getBuildinType()) && Boolean.FALSE.equals(superAdmin)) {
|
||||
throw exception(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
throw new ServiceException(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
}
|
||||
return reportDatasourceDO;
|
||||
}
|
||||
|
||||
+6
-8
@@ -15,7 +15,6 @@ import com.bstek.ureport.definition.dataset.Parameter;
|
||||
import com.bstek.ureport.definition.dataset.SqlDatasetDefinition;
|
||||
import com.bstek.ureport.utils.ProcedureUtils;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@@ -54,7 +53,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_GET_FIELDS_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_INJECTION_RISK;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.DATASET_SQL_REQUIRED;
|
||||
@@ -214,10 +212,10 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
||||
}
|
||||
} catch (BeansException e) {
|
||||
log.error("[ReportDatasourceService][loadBeanMethods]获取bean失败", e);
|
||||
throw ServiceExceptionUtil.exception(DATASOURCE_SPRINGBEAN_GET_FAIL, beanId);
|
||||
throw new ServiceException(DATASOURCE_SPRINGBEAN_GET_FAIL, beanId);
|
||||
} catch (Exception e) {
|
||||
log.error("[ReportDatasourceService][loadBeanMethods]方法列表获取异常", e);
|
||||
throw ServiceExceptionUtil.exception(DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL);
|
||||
throw new ServiceException(DATASOURCE_SPRINGBEAN_METHODS_GET_FAIL);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -230,7 +228,7 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
||||
DataSourceInfo info = previewParams.getInfo();
|
||||
try {
|
||||
if (StringUtils.isEmpty(sql)) {
|
||||
throw exception(DATASET_SQL_REQUIRED);
|
||||
throw new ServiceException(DATASET_SQL_REQUIRED);
|
||||
}
|
||||
// 获取数据库连接
|
||||
conn = MultipleJdbcTemplate.buildConnection(info);
|
||||
@@ -238,7 +236,7 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
||||
for (Parameter parameter : parameters) {
|
||||
// mybatis-plus util检查参数
|
||||
if (SqlInjectionUtils.check(parameter.getDefaultValue())) {
|
||||
throw exception(DATASET_SQL_INJECTION_RISK);
|
||||
throw new ServiceException(DATASET_SQL_INJECTION_RISK);
|
||||
}
|
||||
}
|
||||
// 准备sql执行参数
|
||||
@@ -317,7 +315,7 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
||||
private ReportDatasourceDO validateDatasourceExists(Long id) {
|
||||
ReportDatasourceDO reportDatasourceDO = datasourceMapper.selectNormalDatasourceById(id, SecurityFrameworkUtils.getUserOrganId());
|
||||
if (reportDatasourceDO == null) {
|
||||
throw exception(DATASOURCE_NOT_EXISTS);
|
||||
throw new ServiceException(DATASOURCE_NOT_EXISTS);
|
||||
} else {
|
||||
return reportDatasourceDO;
|
||||
}
|
||||
@@ -331,7 +329,7 @@ public class ReportDatasourceServiceImpl implements ReportDatasourceService {
|
||||
private void validateSystemDatasource(Integer buildinType) {
|
||||
// 非超管不能操作内置模板
|
||||
if (ReportTemplateTypeEnum.SYSTEM.getType().equals(buildinType) && Boolean.FALSE.equals(SecurityFrameworkUtils.isSuperAdmin())) {
|
||||
throw exception(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
throw new ServiceException(DATASOURCE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-14
@@ -41,7 +41,6 @@ import com.bstek.ureport.parser.ReportParser;
|
||||
import com.bstek.ureport.utils.ToolUtils;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
@@ -87,7 +86,6 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_IMPORT_CONTENT_EMPTY_ERROR;
|
||||
import static com.cf.imes.module.report.enums.ErrorCodeConstants.TEMPLATE_NAME_UNIQE_ERROR;
|
||||
@@ -258,7 +256,7 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
boolean isSuperAdmin = SecurityFrameworkUtils.isSuperAdmin();
|
||||
// 非超管不能操作内置模板
|
||||
if (ReportTemplateTypeEnum.SYSTEM.equals(templateDO.getType()) && !isSuperAdmin) {
|
||||
throw exception(TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
throw new ServiceException(TEMPLATE_BUILDIN_OPERATION_PERMISSION_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +278,7 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
reportTemplateDO = templateMapper.selectNormalTemplateById(id, loginUser.getOrganId());
|
||||
}
|
||||
if (ObjectUtil.isNull(reportTemplateDO)) {
|
||||
throw exception(TEMPLATE_NOT_EXISTS);
|
||||
throw new ServiceException(TEMPLATE_NOT_EXISTS);
|
||||
} else {
|
||||
return reportTemplateDO;
|
||||
}
|
||||
@@ -304,7 +302,7 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
wrapper.eq(ReportTemplateDO::getType, ReportTemplateTypeEnum.SYSTEM);
|
||||
}
|
||||
if (templateMapper.exists(wrapper)) {
|
||||
throw exception(TEMPLATE_NAME_UNIQE_ERROR, name);
|
||||
throw new ServiceException(TEMPLATE_NAME_UNIQE_ERROR, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +416,7 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
for (Map.Entry<String, Object> entry : queryMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (ObjectUtils.isEmpty(entry.getValue()) && ObjectUtil.notEqual(key, DATASETIDS_FIELD_NAME) && ObjectUtil.notEqual(key, DATASOURCEIDS_FIELD_NAME)) {
|
||||
throw ServiceExceptionUtil.exception(TEMPLATE_PREIVEW_QUERYPARAM_EMPTY, key);
|
||||
throw new ServiceException(TEMPLATE_PREIVEW_QUERYPARAM_EMPTY, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,12 +515,12 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
// 查询模板
|
||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(reqVO.getTemplateId());
|
||||
if (ObjectUtil.isNull(reportTemplateDO)) {
|
||||
throw exception(TEMPLATE_NOT_EXISTS);
|
||||
throw new ServiceException(TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
// 检查模板内容
|
||||
String content = reportTemplateDO.getContent();
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
throw exception(TEMPLATE_PREVIEW_TEMPLATE_CONTENT_EMPTY_ERROR);
|
||||
throw new ServiceException(TEMPLATE_PREVIEW_TEMPLATE_CONTENT_EMPTY_ERROR);
|
||||
}
|
||||
// 自定义请求vo转ureport对象
|
||||
PreviewParameters params = BeanUtils.toBean(reqVO, PreviewParameters.class);
|
||||
@@ -574,7 +572,7 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
if (inputComponent instanceof TextInputComponent) {
|
||||
Object bindValue = parameters.get(bindParameter);
|
||||
if (parameters.containsKey(bindParameter) && ObjectUtil.isNotNull(bindValue) && StringUtils.isEmpty(String.valueOf(bindValue))) {
|
||||
throw ServiceExceptionUtil.exception(TEMPLATE_PREIVEW_QUERYPARAM_EMPTY, bindParameter);
|
||||
throw new ServiceException(TEMPLATE_PREIVEW_QUERYPARAM_EMPTY, bindParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -625,12 +623,12 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
// 查询模板
|
||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(reqVO.getTemplateId());
|
||||
if (ObjectUtil.isNull(reportTemplateDO)) {
|
||||
throw exception(TEMPLATE_NOT_EXISTS);
|
||||
throw new ServiceException(TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
// 检查模板内容
|
||||
String content = reportTemplateDO.getContent();
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
throw exception(TEMPLATE_PREVIEW_TEMPLATE_CONTENT_EMPTY_ERROR);
|
||||
throw new ServiceException(TEMPLATE_PREVIEW_TEMPLATE_CONTENT_EMPTY_ERROR);
|
||||
}
|
||||
// 自定义请求vo转ureport对象
|
||||
PreviewParameters params = BeanUtils.toBean(reqVO, PreviewParameters.class);
|
||||
@@ -711,12 +709,12 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
// 查询模板
|
||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(reqVO.getTemplateId());
|
||||
if (ObjectUtil.isNull(reportTemplateDO)) {
|
||||
throw exception(TEMPLATE_NOT_EXISTS);
|
||||
throw new ServiceException(TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
// 检查模板内容
|
||||
String content = reportTemplateDO.getContent();
|
||||
if (StringUtils.isEmpty(content)) {
|
||||
throw exception(TEMPLATE_PREVIEW_TEMPLATE_CONTENT_EMPTY_ERROR);
|
||||
throw new ServiceException(TEMPLATE_PREVIEW_TEMPLATE_CONTENT_EMPTY_ERROR);
|
||||
}
|
||||
// 自定义请求vo转ureport对象
|
||||
PreviewParameters params = BeanUtils.toBean(reqVO, PreviewParameters.class);
|
||||
@@ -758,7 +756,7 @@ public class ReportTemplateServiceImpl implements ReportTemplateService {
|
||||
public void exportTemplate(Long templateId, HttpServletResponse response) {
|
||||
ReportTemplateDO reportTemplateDO = validateTemplateExists(templateId);
|
||||
if (ObjectUtil.isNull(reportTemplateDO)) {
|
||||
throw exception(TEMPLATE_NOT_EXISTS);
|
||||
throw new ServiceException(TEMPLATE_NOT_EXISTS);
|
||||
}
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user