refactor: 优化代码结构

This commit is contained in:
wangjiahao 2022-08-31 10:44:40 +08:00
parent c3f94d86f4
commit 2d66c2b0b6
12 changed files with 9 additions and 31 deletions

View File

@ -168,9 +168,7 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe
// NOTE: It's highly recommended to use the ESAPI library and // NOTE: It's highly recommended to use the ESAPI library and
// uncomment the following line to // uncomment the following line to
// avoid encoded attacks. // avoid encoded attacks.
// value = ESAPI.encoder().canonicalize(value);
// Avoid null characters // Avoid null characters
/** value = value.replaceAll("", ""); ***/
// Avoid anything between script tags // Avoid anything between script tags
Pattern scriptPattern = Pattern.compile( Pattern scriptPattern = Pattern.compile(
"<[\r\n| | ]*script[\r\n| | ]*>(.*?)</[\r\n| | ]*script[\r\n| | ]*>", Pattern.CASE_INSENSITIVE); "<[\r\n| | ]*script[\r\n| | ]*>(.*?)</[\r\n| | ]*script[\r\n| | ]*>", Pattern.CASE_INSENSITIVE);

View File

@ -1,5 +1,6 @@
package io.dataease.job.sechedule; package io.dataease.job.sechedule;
import io.dataease.commons.utils.LogUtil;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -12,6 +13,6 @@ import java.util.Date;
public class TestJob extends DeScheduleJob { public class TestJob extends DeScheduleJob {
@Override @Override
void businessExecute(JobExecutionContext context) { void businessExecute(JobExecutionContext context) {
System.out.println("Test Job -- " + new SimpleDateFormat("HH:mm:ss").format(new Date())); LogUtil.info("Test Job -- " + new SimpleDateFormat("HH:mm:ss").format(new Date()));
} }
} }

View File

@ -1,5 +1,6 @@
package io.dataease.listener; package io.dataease.listener;
import io.dataease.commons.utils.LogUtil;
import io.dataease.plugins.common.base.domain.DatasetTableTask; import io.dataease.plugins.common.base.domain.DatasetTableTask;
import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.constants.ScheduleType;
import io.dataease.service.ScheduleService; import io.dataease.service.ScheduleService;
@ -23,7 +24,7 @@ public class AppStartListener implements ApplicationListener<ApplicationReadyEve
@Override @Override
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
System.out.println("================= Application start ================="); LogUtil.info("================= Application start =================");
// 项目启动从数据库读取任务加入到Quartz // 项目启动从数据库读取任务加入到Quartz
List<DatasetTableTask> list = dataSetTableTaskService.list(new DatasetTableTask()); List<DatasetTableTask> list = dataSetTableTaskService.list(new DatasetTableTask());
for (DatasetTableTask task : list) { for (DatasetTableTask task : list) {

View File

@ -31,12 +31,10 @@ public class RowPermissionMergeListener implements ApplicationListener<Applicati
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
Map<String, RowPermissionTreeService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((RowPermissionTreeService.class)); Map<String, RowPermissionTreeService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((RowPermissionTreeService.class));
if (beansOfType.keySet().size() > 0) { if (beansOfType.keySet().size() > 0) {
System.out.println("====row permissions merge [start]====");
logger.info("====row permissions merge [start]===="); logger.info("====row permissions merge [start]====");
SysStartupJob sysStartupJob = sysStartupJobMapper.selectByPrimaryKey(JOB_ID); SysStartupJob sysStartupJob = sysStartupJobMapper.selectByPrimaryKey(JOB_ID);
if (ObjectUtils.isNotEmpty(sysStartupJob) && StringUtils.equalsIgnoreCase(sysStartupJob.getStatus(), "ready")) { if (ObjectUtils.isNotEmpty(sysStartupJob) && StringUtils.equalsIgnoreCase(sysStartupJob.getStatus(), "ready")) {
System.out.println("====row permissions merge [doing]====");
logger.info("====row permissions merge [doing]===="); logger.info("====row permissions merge [doing]====");
RowPermissionTreeService rowPermissionTreeService = SpringContextUtil.getBean(RowPermissionTreeService.class); RowPermissionTreeService rowPermissionTreeService = SpringContextUtil.getBean(RowPermissionTreeService.class);
@ -44,7 +42,6 @@ public class RowPermissionMergeListener implements ApplicationListener<Applicati
sysStartupJob.setStatus("done"); sysStartupJob.setStatus("done");
sysStartupJobMapper.updateByPrimaryKey(sysStartupJob); sysStartupJobMapper.updateByPrimaryKey(sysStartupJob);
} }
System.out.println("====row permissions merge [end]====");
logger.info("====row permissions merge [end]===="); logger.info("====row permissions merge [end]====");
} }
} }

View File

@ -29,7 +29,6 @@ public class SystemInitListener implements ApplicationListener<ApplicationReadyE
@Override @Override
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
System.out.println("=====initSystem from code [Start]=====");
logger.info("=====initSystem from code [Start]====="); logger.info("=====initSystem from code [Start]=====");
Integer dataeseVersion = versionMapper.lastSuccessDataEaseVersion(); Integer dataeseVersion = versionMapper.lastSuccessDataEaseVersion();
Integer dataeseCodeVersion = versionMapper.lastDataEaseCodeVersion(); Integer dataeseCodeVersion = versionMapper.lastDataEaseCodeVersion();
@ -51,8 +50,6 @@ public class SystemInitListener implements ApplicationListener<ApplicationReadyE
codeVersionMapper.insert(codeVersion); codeVersionMapper.insert(codeVersion);
} }
logger.info("=====initSystem from code [End]====="); logger.info("=====initSystem from code [End]=====");
System.out.println("=====initSystem from code [End]=====");
} }
} }

View File

@ -294,7 +294,6 @@ public class MongoQueryProvider extends QueryProvider {
} }
if (CollectionUtils.isNotEmpty(yFields)) { if (CollectionUtils.isNotEmpty(yFields)) {
st_sql.add("aggregators", yFields); st_sql.add("aggregators", yFields);
// st_sql.add("notUseAs", true);
} }
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
@ -497,7 +496,6 @@ public class MongoQueryProvider extends QueryProvider {
} }
if (CollectionUtils.isNotEmpty(yFields)) { if (CollectionUtils.isNotEmpty(yFields)) {
st_sql.add("aggregators", yFields); st_sql.add("aggregators", yFields);
// st_sql.add("notUseAs", true);
} }
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
@ -616,7 +614,6 @@ public class MongoQueryProvider extends QueryProvider {
} }
if (CollectionUtils.isNotEmpty(yFields)) { if (CollectionUtils.isNotEmpty(yFields)) {
st_sql.add("aggregators", yFields); st_sql.add("aggregators", yFields);
// st_sql.add("notUseAs", true);
} }
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
@ -704,7 +701,6 @@ public class MongoQueryProvider extends QueryProvider {
ST st_sql = stg.getInstanceOf("querySql"); ST st_sql = stg.getInstanceOf("querySql");
if (CollectionUtils.isNotEmpty(yFields)) { if (CollectionUtils.isNotEmpty(yFields)) {
st_sql.add("aggregators", yFields); st_sql.add("aggregators", yFields);
// st_sql.add("notUseAs", true);
} }
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres); if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj); if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);

View File

@ -830,14 +830,12 @@ public class ChartViewService {
//如果不是插件视图 走原生逻辑 //如果不是插件视图 走原生逻辑
if (table.getMode() == 0) {// 直连 if (table.getMode() == 0) {// 直连
// Datasource ds = datasourceService.get(table.getDataSourceId());
if (ObjectUtils.isEmpty(ds)) { if (ObjectUtils.isEmpty(ds)) {
throw new RuntimeException(Translator.get("i18n_datasource_delete")); throw new RuntimeException(Translator.get("i18n_datasource_delete"));
} }
if (StringUtils.isNotEmpty(ds.getStatus()) && ds.getStatus().equalsIgnoreCase("Error")) { if (StringUtils.isNotEmpty(ds.getStatus()) && ds.getStatus().equalsIgnoreCase("Error")) {
throw new Exception(Translator.get("i18n_invalid_ds")); throw new Exception(Translator.get("i18n_invalid_ds"));
} }
// DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
datasourceRequest.setDatasource(ds); datasourceRequest.setDatasource(ds);
DataTableInfoDTO dataTableInfoDTO = gson.fromJson(table.getInfo(), DataTableInfoDTO.class); DataTableInfoDTO dataTableInfoDTO = gson.fromJson(table.getInfo(), DataTableInfoDTO.class);
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
@ -903,8 +901,6 @@ public class ChartViewService {
data = datasourceProvider.getData(datasourceRequest); data = datasourceProvider.getData(datasourceRequest);
} else if (table.getMode() == 1) {// 抽取 } else if (table.getMode() == 1) {// 抽取
// 连接doris构建doris数据源查询 // 连接doris构建doris数据源查询
// Datasource ds = engineService.getDeEngine();
// DatasourceProvider datasourceProvider = ProviderFactory.getProvider(ds.getType());
datasourceRequest.setDatasource(ds); datasourceRequest.setDatasource(ds);
String tableName = "ds_" + table.getId().replaceAll("-", "_"); String tableName = "ds_" + table.getId().replaceAll("-", "_");
datasourceRequest.setTable(tableName); datasourceRequest.setTable(tableName);
@ -1154,7 +1150,6 @@ public class ChartViewService {
pluginViewParam.setPluginChartFieldCustomFilters(fieldFilters); pluginViewParam.setPluginChartFieldCustomFilters(fieldFilters);
pluginViewParam.setPluginChartExtFilters(panelFilters); pluginViewParam.setPluginChartExtFilters(panelFilters);
pluginViewParam.setPluginViewLimit(pluginViewLimit); pluginViewParam.setPluginViewLimit(pluginViewLimit);
// pluginViewParam.setUserId(AuthUtils.getUser().getUserId());
return pluginViewParam; return pluginViewParam;
} }

View File

@ -325,27 +325,27 @@ public class ExtractDataService {
try { try {
deleteFile("all_scope", datasetTableId); deleteFile("all_scope", datasetTableId);
} catch (Exception ignore) { } catch (Exception ignore) {
System.out.println(ignore.getMessage()); LogUtil.error(ignore);
} }
try { try {
sendWebMsg(datasetTable, datasetTableTask, datasetTableTaskLog, msg); sendWebMsg(datasetTable, datasetTableTask, datasetTableTaskLog, msg);
} catch (Exception ignore) { } catch (Exception ignore) {
System.out.println(ignore.getMessage()); LogUtil.error(ignore);
} }
try { try {
updateTableStatus(datasetTableId, lastExecStatus, execTime); updateTableStatus(datasetTableId, lastExecStatus, execTime);
} catch (Exception ignore) { } catch (Exception ignore) {
System.out.println(ignore.getMessage()); LogUtil.error(ignore);
} }
try { try {
dataSetTableTaskService.updateTaskStatus(datasetTableTask, lastExecStatus); dataSetTableTaskService.updateTaskStatus(datasetTableTask, lastExecStatus);
} catch (Exception ignore) { } catch (Exception ignore) {
System.out.println(ignore.getMessage()); LogUtil.error(ignore);
} }
try { try {
dropDorisTable(TableUtils.tmpName(TableUtils.tableName(datasetTableId))); dropDorisTable(TableUtils.tmpName(TableUtils.tableName(datasetTableId)));
} catch (Exception ignore) { } catch (Exception ignore) {
System.out.println(ignore.getMessage()); LogUtil.error(ignore);
} }
} }
break; break;

View File

@ -51,7 +51,6 @@ public class PermissionService {
lists.forEach(chartCustomFilterDTO -> { lists.forEach(chartCustomFilterDTO -> {
chartCustomFilterDTO.setFieldId(field.getId()); chartCustomFilterDTO.setFieldId(field.getId());
if(datasetRowPermissions.getAuthTargetType().equalsIgnoreCase("sysParams")){ if(datasetRowPermissions.getAuthTargetType().equalsIgnoreCase("sysParams")){
System.out.println(values.get(chartCustomFilterDTO.getValue()).toString());
chartCustomFilterDTO.setValue(values.get(chartCustomFilterDTO.getValue()).toString()); chartCustomFilterDTO.setValue(values.get(chartCustomFilterDTO.getValue()).toString());
} }
}); });

View File

@ -78,12 +78,10 @@ public class PluginService {
String folder = pluginDir + "folder/"; String folder = pluginDir + "folder/";
try { try {
ZipUtil.unzip(dest.getAbsolutePath(), folder); ZipUtil.unzip(dest.getAbsolutePath(), folder);
// ZipUtils.unzip(dest, folder);
} catch (Exception e) { } catch (Exception e) {
DeFileUtils.deleteFile(pluginDir + "temp/"); DeFileUtils.deleteFile(pluginDir + "temp/");
DeFileUtils.deleteFile(folder); DeFileUtils.deleteFile(folder);
// 需要删除文件 // 需要删除文件
// e.printStackTrace();
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
DEException.throwException(e); DEException.throwException(e);
} }
@ -261,7 +259,6 @@ public class PluginService {
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
//BeanUtils.copyBean(result, myPlugin);
if(result.getCategory().equalsIgnoreCase("datasource") && (StringUtils.isEmpty(result.getStore()) || !result.getStore().equalsIgnoreCase("default"))){ if(result.getCategory().equalsIgnoreCase("datasource") && (StringUtils.isEmpty(result.getStore()) || !result.getStore().equalsIgnoreCase("default"))){
result.setStore("thirdpart"); result.setStore("thirdpart");
} }

View File

@ -140,7 +140,6 @@ public class SysUserService {
sysUser.setLanguage("zh_CN"); sysUser.setLanguage("zh_CN");
sysUser.setFrom(3); sysUser.setFrom(3);
sysUser.setIsAdmin(false); sysUser.setIsAdmin(false);
// sysUser.setSub(ssoUserInfo.getSub());
sysUserMapper.insert(sysUser); sysUserMapper.insert(sysUser);
SysUser dbUser = findOne(sysUser); SysUser dbUser = findOne(sysUser);
if (null != dbUser && null != dbUser.getUserId()) { if (null != dbUser && null != dbUser.getUserId()) {

View File

@ -238,7 +238,6 @@ public class LogService {
} }
public void saveLog(SysLogDTO sysLogDTO) { public void saveLog(SysLogDTO sysLogDTO) {
// String ip = "";
CurrentUserDto user = AuthUtils.getUser(); CurrentUserDto user = AuthUtils.getUser();
SysLogWithBLOBs sysLogWithBLOBs = BeanUtils.copyBean(new SysLogWithBLOBs(), sysLogDTO); SysLogWithBLOBs sysLogWithBLOBs = BeanUtils.copyBean(new SysLogWithBLOBs(), sysLogDTO);
if (CollectionUtils.isNotEmpty(sysLogDTO.getPositions())) { if (CollectionUtils.isNotEmpty(sysLogDTO.getPositions())) {
@ -258,7 +257,6 @@ public class LogService {
sysLogWithBLOBs.setNickName(sysLogDTO.getSourceName()); sysLogWithBLOBs.setNickName(sysLogDTO.getSourceName());
} }
// sysLogWithBLOBs.setIp(ip);
sysLogMapper.insert(sysLogWithBLOBs); sysLogMapper.insert(sysLogWithBLOBs);
} }