forked from github/dataease
Merge pull request #7583 from dataease/pr@dev-v2@perf_remove_hutool
perf: 移除hutool
This commit is contained in:
commit
4953bb5d3c
@ -1,6 +1,5 @@
|
||||
package io.dataease.chart.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import io.dataease.api.chart.dto.*;
|
||||
import io.dataease.api.chart.request.ChartDrillRequest;
|
||||
import io.dataease.api.chart.request.ChartExtRequest;
|
||||
@ -32,12 +31,13 @@ import io.dataease.system.manage.CorePermissionManage;
|
||||
import io.dataease.utils.BeanUtils;
|
||||
import io.dataease.utils.JsonUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@ -246,7 +246,7 @@ public class ChartDataManage {
|
||||
|
||||
boolean hasParameters = false;
|
||||
List<SqlVariableDetails> sqlVariables = datasetGroupManage.getSqlParams(Arrays.asList(view.getTableId()));
|
||||
if (CollectionUtil.isNotEmpty(sqlVariables)) {
|
||||
if (CollectionUtils.isNotEmpty(sqlVariables)) {
|
||||
for (SqlVariableDetails parameter : Optional.ofNullable(request.getParameters()).orElse(new ArrayList<>())) {
|
||||
String parameterId = StringUtils.endsWith(parameter.getId(), START_END_SEPARATOR) ? parameter.getId().split(START_END_SEPARATOR)[0] : parameter.getId();
|
||||
if (sqlVariables.stream().map(SqlVariableDetails::getId).collect(Collectors.toList()).contains(parameterId)) {
|
||||
@ -1146,8 +1146,8 @@ public class ChartDataManage {
|
||||
getIndex += xAxis.size();
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(fieldType, "extStack")) {
|
||||
int xAxisSize = CollectionUtil.size(view.getXAxis());
|
||||
int extSize = CollectionUtil.size(view.getXAxisExt());
|
||||
int xAxisSize = CollectionUtils.size(view.getXAxis());
|
||||
int extSize = CollectionUtils.size(view.getXAxisExt());
|
||||
index += xAxisSize + extSize;
|
||||
getIndex += xAxisSize + extSize;
|
||||
}
|
||||
@ -1326,7 +1326,7 @@ public class ChartDataManage {
|
||||
}
|
||||
|
||||
public void saveChartViewFromVisualization(String checkData, Long sceneId, Map<Long, ChartViewDTO> chartViewsInfo) {
|
||||
if (!CollectionUtils.isEmpty(chartViewsInfo)) {
|
||||
if (!MapUtils.isEmpty(chartViewsInfo)) {
|
||||
chartViewsInfo.forEach((key, chartViewDTO) -> {
|
||||
if (checkData.indexOf(chartViewDTO.getId() + "") > -1) {
|
||||
try {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.chart.server;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.api.chart.ChartDataApi;
|
||||
import io.dataease.api.chart.dto.ChartViewDTO;
|
||||
import io.dataease.api.chart.dto.ViewDetailField;
|
||||
@ -15,18 +14,14 @@ import io.dataease.visualization.manage.VisualizationTemplateExtendDataManage;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -50,9 +45,9 @@ public class ChartDataServer implements ChartDataApi {
|
||||
public ChartViewDTO getData(ChartViewDTO chartViewDTO) throws Exception {
|
||||
try {
|
||||
// 从模板数据获取
|
||||
if(CommonConstants.VIEW_DATA_FROM.TEMPLATE.equalsIgnoreCase(chartViewDTO.getDataFrom())){
|
||||
return extendDataManage.getChartDataInfo(chartViewDTO.getId(),chartViewDTO);
|
||||
}else{
|
||||
if (CommonConstants.VIEW_DATA_FROM.TEMPLATE.equalsIgnoreCase(chartViewDTO.getDataFrom())) {
|
||||
return extendDataManage.getChartDataInfo(chartViewDTO.getId(), chartViewDTO);
|
||||
} else {
|
||||
return chartDataManage.calcData(chartViewDTO);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -85,7 +80,7 @@ public class ChartDataServer implements ChartDataApi {
|
||||
|
||||
@Override
|
||||
public void innerExportDetails(ChartExcelRequest request, HttpServletResponse response) throws Exception {
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
try {
|
||||
findExcelData(request);
|
||||
List<Object[]> details = request.getDetails();
|
||||
@ -114,7 +109,7 @@ public class ChartDataServer implements ChartDataApi {
|
||||
|
||||
Boolean mergeHead = false;
|
||||
ViewDetailField[] detailFields = request.getDetailFields();
|
||||
if (ArrayUtil.isNotEmpty(detailFields)) {
|
||||
if (ArrayUtils.isNotEmpty(detailFields)) {
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
@ -199,7 +194,7 @@ public class ChartDataServer implements ChartDataApi {
|
||||
} else if (cellValObj != null) {
|
||||
try {
|
||||
// with DataType
|
||||
if ((excelTypes[j].equals(DeTypeConstants.DE_INT) || excelTypes[j] .equals(DeTypeConstants.DE_FLOAT) ) && StringUtils.isNotEmpty(cellValObj.toString())) {
|
||||
if ((excelTypes[j].equals(DeTypeConstants.DE_INT) || excelTypes[j].equals(DeTypeConstants.DE_FLOAT)) && StringUtils.isNotEmpty(cellValObj.toString())) {
|
||||
cell.setCellValue(Double.valueOf(cellValObj.toString()));
|
||||
} else {
|
||||
cell.setCellValue(cellValObj.toString());
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.dataease.chart.utils;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.api.chart.dto.*;
|
||||
import io.dataease.utils.IDUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -1004,7 +1004,7 @@ public class ChartDataBuild {
|
||||
Map<String, Object> map = transTableNormal(fields, null, data, desensitizationList);
|
||||
List<Map<String, Object>> tableRow = (List<Map<String, Object>>) map.get("tableRow");
|
||||
final int xEndIndex = detailIndex;
|
||||
Map<String, List<String[]>> groupDataList = detailData.stream().collect(Collectors.groupingBy(item -> ArrayUtil.join(ArrayUtil.sub(item, 0, xEndIndex), "-de-", "(", ")")));
|
||||
Map<String, List<String[]>> groupDataList = detailData.stream().collect(Collectors.groupingBy(item -> "(" + StringUtils.join(ArrayUtils.subarray(item, 0, xEndIndex), "-de-") + ")"));
|
||||
|
||||
tableRow.forEach(row -> {
|
||||
String key = xAxis.stream().map(x -> String.format(format, row.get(x.getDataeaseName()).toString())).collect(Collectors.joining("-de-"));
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.dataset.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.dataease.api.dataset.dto.DatasetTableDTO;
|
||||
@ -32,6 +31,7 @@ import io.dataease.operation.manage.CoreOptRecentManage;
|
||||
import io.dataease.system.manage.CoreUserManage;
|
||||
import io.dataease.utils.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -211,7 +211,7 @@ public class DatasetGroupManage {
|
||||
List<DataSetNodeBO> nodes = new ArrayList<>();
|
||||
if (ObjectUtils.isEmpty(request.getLeaf()) || !request.getLeaf()) nodes.add(rootNode());
|
||||
List<DataSetNodeBO> bos = pos.stream().map(this::convert).toList();
|
||||
if (CollectionUtil.isNotEmpty(bos)) {
|
||||
if (CollectionUtils.isNotEmpty(bos)) {
|
||||
nodes.addAll(bos);
|
||||
}
|
||||
return TreeUtils.mergeTree(nodes, BusiNodeVO.class, false);
|
||||
@ -449,10 +449,11 @@ public class DatasetGroupManage {
|
||||
for (CoreDatasetTable datasetTable : datasetTables) {
|
||||
if (StringUtils.isNotEmpty(datasetTable.getSqlVariableDetails())) {
|
||||
List<SqlVariableDetails> defaultsSqlVariableDetails = JsonUtil.parseList(datasetTable.getSqlVariableDetails(), listTypeReference);
|
||||
if (CollectionUtil.isNotEmpty(defaultsSqlVariableDetails)) {
|
||||
if (CollectionUtils.isNotEmpty(defaultsSqlVariableDetails)) {
|
||||
List<String> fullName = new ArrayList<>();
|
||||
geFullName(id, fullName);
|
||||
List<String> finalFullName = CollectionUtil.reverse(fullName);
|
||||
Collections.reverse(fullName);
|
||||
List<String> finalFullName = fullName;
|
||||
defaultsSqlVariableDetails.forEach(sqlVariableDetails -> {
|
||||
sqlVariableDetails.setDatasetGroupId(id);
|
||||
sqlVariableDetails.setDatasetTableId(datasetTable.getId());
|
||||
@ -500,13 +501,13 @@ public class DatasetGroupManage {
|
||||
|
||||
public List<DatasetTableDTO> getDetailWithPerm(List<Long> ids) {
|
||||
var result = new ArrayList<DatasetTableDTO>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
var dsList = coreDatasetGroupMapper.selectBatchIds(ids);
|
||||
if (CollectionUtil.isNotEmpty(dsList)) {
|
||||
if (CollectionUtils.isNotEmpty(dsList)) {
|
||||
dsList.forEach(ds -> {
|
||||
DatasetTableDTO dto = new DatasetTableDTO();
|
||||
BeanUtils.copyBean(dto, ds);
|
||||
var fields = datasetTableFieldManage.listFieldsWithPermissions(ds.getId());
|
||||
var fields = datasetTableFieldManage.listFieldsWithPermissions(ds.getId());
|
||||
List<DatasetTableFieldDTO> dimensionList = fields.stream().filter(ele -> StringUtils.equalsIgnoreCase(ele.getGroupType(), "d")).toList();
|
||||
List<DatasetTableFieldDTO> quotaList = fields.stream().filter(ele -> StringUtils.equalsIgnoreCase(ele.getGroupType(), "q")).toList();
|
||||
Map<String, List<DatasetTableFieldDTO>> map = new LinkedHashMap<>();
|
||||
|
@ -1,9 +1,7 @@
|
||||
package io.dataease.dataset.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.dataease.api.chart.dto.ColumnPermissionItem;
|
||||
import io.dataease.auth.bo.TokenUserBO;
|
||||
import io.dataease.dataset.dao.auto.entity.CoreDatasetTableField;
|
||||
import io.dataease.dataset.dao.auto.mapper.CoreDatasetGroupMapper;
|
||||
import io.dataease.dataset.dao.auto.mapper.CoreDatasetTableFieldMapper;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.datasource.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.dataease.api.ds.vo.DatasourceDTO;
|
||||
@ -19,6 +18,7 @@ import io.dataease.operation.manage.CoreOptRecentManage;
|
||||
import io.dataease.utils.AuthUtils;
|
||||
import io.dataease.utils.TreeUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -65,7 +65,7 @@ public class DataSourceManage {
|
||||
List<DatasourceNodeBO> nodes = new ArrayList<>();
|
||||
List<DataSourceNodePO> pos = dataSourceExtMapper.selectList(queryWrapper);
|
||||
if (ObjectUtils.isEmpty(request.getLeaf()) || !request.getLeaf()) nodes.add(rootNode());
|
||||
if (CollectionUtil.isNotEmpty(pos)) {
|
||||
if (CollectionUtils.isNotEmpty(pos)) {
|
||||
nodes.addAll(pos.stream().map(this::convert).toList());
|
||||
}
|
||||
return TreeUtils.mergeTree(nodes, BusiNodeVO.class, false);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.datasource.server;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -42,13 +41,13 @@ import io.dataease.system.dao.auto.entity.CoreSysSetting;
|
||||
import io.dataease.system.manage.CoreUserManage;
|
||||
import io.dataease.utils.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -168,7 +167,7 @@ public class DatasourceServer implements DatasourceApi {
|
||||
ids.add(busiNodeVO.getId());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(busiNodeVO.getChildren())) {
|
||||
if (CollectionUtils.isNotEmpty(busiNodeVO.getChildren())) {
|
||||
filterDs(busiNodeVO.getChildren(), ids, type, id);
|
||||
}
|
||||
}
|
||||
@ -184,14 +183,14 @@ public class DatasourceServer implements DatasourceApi {
|
||||
List<Long> ids = new ArrayList<>();
|
||||
filterDs(busiNodeVOS, ids, dataSourceDTO.getType(), dataSourceDTO.getId());
|
||||
|
||||
if (CollectionUtil.isEmpty(ids)) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
QueryWrapper<CoreDatasource> wrapper = new QueryWrapper<>();
|
||||
wrapper.in("id", ids);
|
||||
|
||||
List<CoreDatasource> datasources = datasourceMapper.selectList(wrapper);
|
||||
if (CollectionUtil.isEmpty(datasources)) {
|
||||
if (CollectionUtils.isEmpty(datasources)) {
|
||||
return false;
|
||||
}
|
||||
dataSourceDTO.setConfiguration(new String(Base64.getDecoder().decode(dataSourceDTO.getConfiguration())));
|
||||
|
@ -1,7 +1,5 @@
|
||||
package io.dataease.map.manage;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.dataease.api.map.dto.GeometryNodeCreator;
|
||||
import io.dataease.api.map.vo.AreaNode;
|
||||
@ -14,6 +12,7 @@ import io.dataease.map.dao.ext.entity.CoreAreaCustom;
|
||||
import io.dataease.map.dao.ext.mapper.CoreAreaCustomMapper;
|
||||
import io.dataease.utils.BeanUtils;
|
||||
import io.dataease.utils.CommonBeanFactory;
|
||||
import io.dataease.utils.FileUtils;
|
||||
import io.dataease.utils.LogUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -32,7 +31,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.dataease.constant.CacheConstant.CommonCacheConstant.WORLD_MAP_CACHE;
|
||||
|
||||
@ -114,7 +112,8 @@ public class MapManage {
|
||||
if (ObjectUtils.isEmpty(file) || file.isEmpty()) {
|
||||
DEException.throwException("geometry file is require");
|
||||
}
|
||||
String suffix = FileUtil.getSuffix(file.getOriginalFilename());
|
||||
|
||||
String suffix = FileUtils.getExtensionName(file.getOriginalFilename());
|
||||
if (!StringUtils.equalsIgnoreCase("json", suffix)) {
|
||||
DEException.throwException("仅支持json格式文件");
|
||||
}
|
||||
@ -164,7 +163,7 @@ public class MapManage {
|
||||
}
|
||||
List<String> codeResultList = new ArrayList<>();
|
||||
codeResultList.add(code);
|
||||
childTreeIdList(ListUtil.of(code), codeResultList);
|
||||
childTreeIdList(List.of(code), codeResultList);
|
||||
coreAreaCustomMapper.deleteBatchIds(codeResultList);
|
||||
codeResultList.forEach(id -> {
|
||||
File file = buildGeoFile(id);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.menu.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.dataease.api.menu.vo.MenuMeta;
|
||||
import io.dataease.api.menu.vo.MenuVO;
|
||||
@ -10,6 +9,7 @@ import io.dataease.menu.dao.auto.entity.CoreMenu;
|
||||
import io.dataease.menu.dao.auto.mapper.CoreMenuMapper;
|
||||
import io.dataease.utils.BeanUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -61,10 +61,10 @@ public class MenuManage {
|
||||
for (MenuTreeNode menuTreeNode : roots) {
|
||||
MenuVO vo = convert(menuTreeNode);
|
||||
List<MenuTreeNode> children = null;
|
||||
if (CollectionUtil.isNotEmpty(children = menuTreeNode.getChildren())) {
|
||||
if (CollectionUtils.isNotEmpty(children = menuTreeNode.getChildren())) {
|
||||
vo.setChildren(convertTree(children));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(vo.getChildren()) || menuTreeNode.getType() != 1) {
|
||||
if (CollectionUtils.isNotEmpty(vo.getChildren()) || menuTreeNode.getType() != 1) {
|
||||
result.add(vo);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package io.dataease.operation.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.dataease.commons.constants.OptConstants;
|
||||
import io.dataease.operation.dao.auto.entity.CoreOptRecent;
|
||||
import io.dataease.operation.dao.auto.mapper.CoreOptRecentMapper;
|
||||
import io.dataease.utils.AuthUtils;
|
||||
import io.dataease.utils.IDUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -64,7 +64,7 @@ public class CoreOptRecentManage {
|
||||
queryWrapper.eq("resource_type", OptConstants.OPT_RESOURCE_TYPE.TEMPLATE);
|
||||
queryWrapper.eq("uid", uid);
|
||||
List<CoreOptRecent> result = coreStoreMapper.selectList(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (CollectionUtils.isNotEmpty(result)) {
|
||||
return result.stream().collect(Collectors.toMap(CoreOptRecent::getResourceName, CoreOptRecent::getTime));
|
||||
} else {
|
||||
return new HashMap<>();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.visualization.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -24,6 +23,7 @@ import io.dataease.visualization.dao.ext.po.VisualizationNodePO;
|
||||
import io.dataease.visualization.dao.ext.po.VisualizationResourcePO;
|
||||
import io.dataease.visualization.dto.VisualizationNodeBO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -56,12 +56,12 @@ public class CoreVisualizationManage {
|
||||
}
|
||||
QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
queryWrapper.ne("pid",-1);
|
||||
queryWrapper.ne("pid", -1);
|
||||
queryWrapper.eq(ObjectUtils.isNotEmpty(request.getLeaf()), "node_type", ObjectUtils.isNotEmpty(request.getLeaf()) && request.getLeaf() ? "leaf" : "folder");
|
||||
queryWrapper.eq("type", request.getBusiFlag());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
List<VisualizationNodePO> pos = extMapper.queryNodes(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(pos)) {
|
||||
if (CollectionUtils.isNotEmpty(pos)) {
|
||||
nodes.addAll(pos.stream().map(this::convert).toList());
|
||||
}
|
||||
return TreeUtils.mergeTree(nodes, BusiNodeVO.class, false);
|
||||
@ -81,7 +81,7 @@ public class CoreVisualizationManage {
|
||||
if (isTopNode(tempPid)) continue;
|
||||
delIds.add(tempPid);
|
||||
List<Long> childrenIdList = extMapper.queryChildrenId(tempPid);
|
||||
if (CollectionUtil.isNotEmpty(childrenIdList)) {
|
||||
if (CollectionUtils.isNotEmpty(childrenIdList)) {
|
||||
childrenIdList.forEach(kid -> {
|
||||
if (!delIds.contains(kid)) {
|
||||
stack.add(kid);
|
||||
@ -112,7 +112,7 @@ public class CoreVisualizationManage {
|
||||
return preInnerSave(visualizationInfo);
|
||||
}
|
||||
|
||||
public Long preInnerSave(DataVisualizationInfo visualizationInfo){
|
||||
public Long preInnerSave(DataVisualizationInfo visualizationInfo) {
|
||||
if (visualizationInfo.getId() == null) {
|
||||
Long id = IDUtils.snowID();
|
||||
visualizationInfo.setId(id);
|
||||
@ -169,7 +169,7 @@ public class CoreVisualizationManage {
|
||||
}
|
||||
|
||||
List<VisualizationResourceVO> formatResult(List<VisualizationResourcePO> pos) {
|
||||
if (CollectionUtil.isEmpty(pos)) {
|
||||
if (CollectionUtils.isEmpty(pos)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return pos.stream().map(po ->
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.visualization.manage;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -18,6 +17,7 @@ import io.dataease.visualization.dao.auto.mapper.CoreStoreMapper;
|
||||
import io.dataease.visualization.dao.ext.mapper.CoreStoreExtMapper;
|
||||
import io.dataease.visualization.dao.ext.po.StorePO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -84,7 +84,7 @@ public class VisualizationStoreManage {
|
||||
}
|
||||
|
||||
public List<VisualizationStoreVO> formatResult(List<StorePO> pos) {
|
||||
if (CollectionUtil.isEmpty(pos)) return new ArrayList<>();
|
||||
if (CollectionUtils.isEmpty(pos)) return new ArrayList<>();
|
||||
return pos.stream().map(po ->
|
||||
new VisualizationStoreVO(
|
||||
po.getStoreId(), po.getResourceId(), po.getName(),
|
||||
|
@ -1,8 +1,6 @@
|
||||
package io.dataease.visualization.server;
|
||||
|
||||
|
||||
import cn.hutool.core.codec.Base64Decoder;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import io.dataease.api.visualization.StaticResourceApi;
|
||||
import io.dataease.api.visualization.request.StaticResourceRequest;
|
||||
import io.dataease.exception.DEException;
|
||||
@ -10,8 +8,10 @@ import io.dataease.utils.FileUtils;
|
||||
import io.dataease.utils.JsonUtil;
|
||||
import io.dataease.utils.LogUtil;
|
||||
import io.dataease.utils.StaticResourceUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -89,17 +89,18 @@ public class StaticResourceServer implements StaticResourceApi {
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(content)) {
|
||||
Files.createFile(uploadPath);
|
||||
FileCopyUtils.copy(Base64Decoder.decode(content), Files.newOutputStream(uploadPath));
|
||||
FileCopyUtils.copy(Base64Utils.decodeFromString(content), Files.newOutputStream(uploadPath));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("template static resource save error" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> findResourceAsBase64(StaticResourceRequest resourceRequest) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
if (CollectionUtil.isNotEmpty(resourceRequest.getResourcePathList())) {
|
||||
if (CollectionUtils.isNotEmpty(resourceRequest.getResourcePathList())) {
|
||||
for (String path : resourceRequest.getResourcePathList()) {
|
||||
String value = StaticResourceUtils.getImgFileToBase64(path.substring(path.lastIndexOf("/") + 1, path.length()));
|
||||
result.put(path, value);
|
||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
||||
Subproject commit d17d3775defcb7bbe2603121a417982a0811af4f
|
||||
Subproject commit 8b378277440ec171aa960a537274017d0609551b
|
11
pom.xml
11
pom.xml
@ -31,7 +31,6 @@
|
||||
<java-jwt.version>3.12.1</java-jwt.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<maven.antrun.version>3.1.0</maven.antrun.version>
|
||||
<hutool.version>5.8.24</hutool.version>
|
||||
<ehcache.version>3.10.8</ehcache.version>
|
||||
<bcprov.version>1.74</bcprov.version>
|
||||
<junit.version>4.13.2</junit.version>
|
||||
@ -116,16 +115,6 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
|
@ -3,10 +3,12 @@ package io.dataease.api.permissions.auth.dto;
|
||||
import io.dataease.api.permissions.auth.vo.PermissionItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "业务权限编辑器")
|
||||
@Data
|
||||
public class BusiPerEditor extends BusiPermissionRequest implements Serializable {
|
||||
|
@ -2,6 +2,9 @@ package io.dataease.api.permissions.auth.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "资源权限构造器")
|
||||
@Data
|
||||
public class BusiTargetPerCreator extends MenuTargetPerCreator{
|
||||
|
@ -3,11 +3,13 @@ package io.dataease.api.permissions.auth.dto;
|
||||
import io.dataease.api.permissions.auth.vo.PermissionItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "菜单权限编辑器")
|
||||
@Data
|
||||
public class MenuPerEditor extends MenuPermissionRequest implements Serializable {
|
||||
|
@ -3,8 +3,10 @@ package io.dataease.api.permissions.auth.dto;
|
||||
import io.dataease.api.permissions.auth.vo.PermissionItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "菜单权限构造器")
|
||||
@Data
|
||||
public class MenuTargetPerCreator extends TargetPerCreator{
|
||||
|
@ -2,8 +2,10 @@ package io.dataease.api.permissions.auth.dto;
|
||||
|
||||
import io.dataease.api.permissions.auth.vo.PermissionItem;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PermissionBO extends PermissionItem {
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package io.dataease.api.permissions.dataset.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author gin
|
||||
* @Date 2022/7/19 20:23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class DatasetRowPermissionsTreeRequest extends DataSetRowPermissionsTreeDTO {
|
||||
public String orderBy;
|
||||
|
@ -5,7 +5,9 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.dataease.api.permissions.role.dto.RoleCreator;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "角色详情VO")
|
||||
@Data
|
||||
public class RoleDetailVO extends RoleCreator {
|
||||
|
@ -2,9 +2,11 @@ package io.dataease.api.permissions.user.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "用户编辑器")
|
||||
@Data
|
||||
public class UserEditor extends UserCreator{
|
||||
|
@ -1,15 +1,17 @@
|
||||
package io.dataease.auth.interceptor;
|
||||
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import io.dataease.utils.CommonBeanFactory;
|
||||
import io.dataease.utils.DeReflectUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -51,7 +53,8 @@ public class CorsInterceptor implements HandlerInterceptor {
|
||||
bean = CommonBeanFactory.getBean(aClass);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(bean)) {
|
||||
Object result = ReflectUtil.invoke(bean, methodName);
|
||||
Method method = DeReflectUtil.findMethod(aClass, methodName);
|
||||
Object result = ReflectionUtils.invokeMethod(method, bean);
|
||||
if (ObjectUtils.isNotEmpty(result)) {
|
||||
List<String> list = (List<String>) result;
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package io.dataease.doc;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -22,10 +22,10 @@ public class SwaggerConfig {
|
||||
@Bean
|
||||
public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() {
|
||||
return openApi -> {
|
||||
if (openApi.getTags()!=null){
|
||||
if (openApi.getTags() != null) {
|
||||
openApi.getTags().forEach(tag -> {
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("x-order", RandomUtil.randomInt(0,100));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("x-order", RandomUtils.nextInt(0, 100));
|
||||
tag.setExtensions(map);
|
||||
});
|
||||
}
|
||||
@ -48,7 +48,6 @@ public class SwaggerConfig {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi visualizationApi() {
|
||||
return GroupedOpenApi.builder().group("1-visualization").displayName("可视化管理").packagesToScan("io.dataease.visualization").build();
|
||||
@ -89,6 +88,4 @@ public class SwaggerConfig {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class DeReflectUtil {
|
||||
|
||||
public static Method findMethod(Class<?> cla, String methodName) {
|
||||
Method[] methods = cla.getMethods();
|
||||
if (ArrayUtils.isEmpty(methods)) return null;
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName)){
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,18 +1,20 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
public class IDUtils {
|
||||
|
||||
private static SnowFlake snowFlake = new SnowFlake(1, 1);
|
||||
|
||||
public static String randomID(Integer num) {
|
||||
num = ObjectUtils.isEmpty(num) ? 16 : num;
|
||||
return RandomUtil.randomString(16);
|
||||
return RandomStringUtils.randomAlphanumeric(num);
|
||||
}
|
||||
|
||||
// 主键请不要使用字符串 推荐雪花算法
|
||||
public static Long snowID() {
|
||||
return IdUtil.getSnowflakeNextId();
|
||||
return snowFlake.nextId();
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,42 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.model.RSAModel;
|
||||
import io.dataease.rsa.dao.entity.CoreRsa;
|
||||
import io.dataease.rsa.manage.RsaManage;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Security;
|
||||
import java.security.*;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
|
||||
@Component
|
||||
public class RsaUtils {
|
||||
|
||||
static {
|
||||
if (ObjectUtils.isNotEmpty(Security.getProvider("BC"))) {
|
||||
Security.removeProvider("BC");
|
||||
}
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
}
|
||||
|
||||
|
||||
private static final int MAX_ENCRYPT_BLOCK = 117;
|
||||
|
||||
private static final int MAX_DECRYPT_BLOCK = 128;
|
||||
|
||||
private static final String PK_SEPARATOR = "-pk_separator-";
|
||||
|
||||
private static RsaManage rsaManage;
|
||||
@ -27,20 +46,108 @@ public class RsaUtils {
|
||||
RsaUtils.rsaManage = rsaManage;
|
||||
}
|
||||
|
||||
private static KeyPair getKeyPair() {
|
||||
KeyPairGenerator generator = null;
|
||||
try {
|
||||
generator = KeyPairGenerator.getInstance("RSA");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
}
|
||||
generator.initialize(1024);
|
||||
return generator.generateKeyPair();
|
||||
}
|
||||
|
||||
private static PrivateKey getPrivateKey(String privateKey) {
|
||||
KeyFactory keyFactory = null;
|
||||
try {
|
||||
keyFactory = KeyFactory.getInstance("RSA");
|
||||
byte[] decodedKey = Base64.decodeBase64(privateKey.getBytes());
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(decodedKey);
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static PublicKey getPublicKey(String publicKey) {
|
||||
KeyFactory keyFactory = null;
|
||||
try {
|
||||
keyFactory = KeyFactory.getInstance("RSA");
|
||||
byte[] decodedKey = Base64.decodeBase64(publicKey.getBytes());
|
||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(decodedKey);
|
||||
return keyFactory.generatePublic(keySpec);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String encrypt(String data, PublicKey publicKey) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
int inputLen = data.getBytes().length;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int offset = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
while (inputLen - offset > 0) {
|
||||
if (inputLen - offset > MAX_ENCRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(data.getBytes(), offset, MAX_ENCRYPT_BLOCK);
|
||||
} else {
|
||||
cache = cipher.doFinal(data.getBytes(), offset, inputLen - offset);
|
||||
}
|
||||
out.write(cache, 0, cache.length);
|
||||
i++;
|
||||
offset = i * MAX_ENCRYPT_BLOCK;
|
||||
}
|
||||
byte[] encryptedData = out.toByteArray();
|
||||
out.close();
|
||||
return Base64.encodeBase64String(encryptedData);
|
||||
}
|
||||
|
||||
private static String decrypt(String data, PrivateKey privateKey) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
byte[] dataBytes = Base64.decodeBase64(data);
|
||||
int inputLen = dataBytes.length;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int offset = 0;
|
||||
byte[] cache;
|
||||
int i = 0;
|
||||
while (inputLen - offset > 0) {
|
||||
if (inputLen - offset > MAX_DECRYPT_BLOCK) {
|
||||
cache = cipher.doFinal(dataBytes, offset, MAX_DECRYPT_BLOCK);
|
||||
} else {
|
||||
cache = cipher.doFinal(dataBytes, offset, inputLen - offset);
|
||||
}
|
||||
out.write(cache, 0, cache.length);
|
||||
i++;
|
||||
offset = i * MAX_DECRYPT_BLOCK;
|
||||
}
|
||||
out.close();
|
||||
return out.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static RSAModel generate() {
|
||||
RSA rsa = new RSA();
|
||||
String privateKeyBase64 = rsa.getPrivateKeyBase64();
|
||||
String publicKeyBase64 = rsa.getPublicKeyBase64();
|
||||
KeyPair keyPair = getKeyPair();
|
||||
String privateKey = new String(Base64.encodeBase64(keyPair.getPrivate().getEncoded()));
|
||||
String publicKey = new String(Base64.encodeBase64(keyPair.getPublic().getEncoded()));
|
||||
RSAModel rsaModel = new RSAModel();
|
||||
rsaModel.setPrivateKey(privateKeyBase64);
|
||||
rsaModel.setPublicKey(publicKeyBase64);
|
||||
rsaModel.setPrivateKey(privateKey);
|
||||
rsaModel.setPublicKey(publicKey);
|
||||
rsaModel.setAesKey(generateAesKey());
|
||||
return rsaModel;
|
||||
}
|
||||
|
||||
public static String decryptStr(String data, String privateKey) {
|
||||
RSA rsa = new RSA(privateKey, null);
|
||||
return rsa.decryptStr(data, KeyType.PrivateKey);
|
||||
try {
|
||||
return decrypt(data, getPrivateKey(privateKey));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String decryptStr(String data) {
|
||||
@ -48,8 +155,12 @@ public class RsaUtils {
|
||||
}
|
||||
|
||||
public static String encryptStr(String data) {
|
||||
RSA rsa = new RSA(privateKey(), publicKey());
|
||||
return rsa.encryptBase64(data, KeyType.PublicKey);
|
||||
try {
|
||||
return encrypt(data, getPublicKey(publicKey()));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String privateKey() {
|
||||
@ -61,23 +172,40 @@ public class RsaUtils {
|
||||
CoreRsa coreRsa = rsaManage.query();
|
||||
String publicKey = coreRsa.getPublicKey();
|
||||
String aesKey = coreRsa.getAesKey();
|
||||
// Security.addProvider(new BouncyCastleProvider());
|
||||
String pk = ascEncrypt(publicKey, aesKey);
|
||||
String pk = ascEncrypt(publicKey, aesKey).replaceAll("[\\s*\t\n\r]", "");
|
||||
String separator = Base64Utils.encodeToUrlSafeString(PK_SEPARATOR.getBytes(StandardCharsets.UTF_8));
|
||||
return pk + separator + aesKey;
|
||||
}
|
||||
|
||||
private static final String IV_KEY = "0000000000000000";
|
||||
|
||||
private static String generateAesKey() {
|
||||
return RandomUtil.randomString(16);
|
||||
return RandomStringUtils.randomAlphanumeric(16);
|
||||
}
|
||||
|
||||
private static String ascEncrypt(String message, String key) {
|
||||
byte[] baseKey = key.getBytes(StandardCharsets.UTF_8);
|
||||
/*byte[] baseKey = key.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ivBytes = IV_KEY.getBytes(StandardCharsets.UTF_8);
|
||||
AES aes = new AES("CBC", "PKCS7Padding", baseKey, ivBytes);
|
||||
byte[] messageBytes = message.getBytes(StandardCharsets.UTF_8);
|
||||
return Base64Utils.encodeToString(aes.encrypt(messageBytes));
|
||||
return Base64Utils.encodeToString(aes.encrypt(messageBytes));*/
|
||||
|
||||
Cipher cipher = null;
|
||||
try {
|
||||
byte[] baseKey = key.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ivBytes = IV_KEY.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] messageBytes = message.getBytes(StandardCharsets.UTF_8);
|
||||
cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
|
||||
// 根据secretKey(密钥)的字节内容,"恢复"秘钥对象
|
||||
SecretKey keySpec = new SecretKeySpec(baseKey, "AES");
|
||||
IvParameterSpec ivps = new IvParameterSpec(ivBytes);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivps);
|
||||
byte[] data = cipher.doFinal(messageBytes);
|
||||
return Base64.encodeBase64String(data);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
89
sdk/common/src/main/java/io/dataease/utils/SnowFlake.java
Normal file
89
sdk/common/src/main/java/io/dataease/utils/SnowFlake.java
Normal file
@ -0,0 +1,89 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
public class SnowFlake {
|
||||
|
||||
/**
|
||||
* 起始的时间戳
|
||||
*/
|
||||
private final static long START_STMP = 1480166465631L;
|
||||
|
||||
/**
|
||||
* 每一部分占用的位数
|
||||
*/
|
||||
private final static long SEQUENCE_BIT = 12; //序列号占用的位数
|
||||
private final static long MACHINE_BIT = 5; //机器标识占用的位数
|
||||
private final static long DATACENTER_BIT = 5;//数据中心占用的位数
|
||||
|
||||
/**
|
||||
* 每一部分的最大值
|
||||
*/
|
||||
private final static long MAX_DATACENTER_NUM = -1L ^ (-1L << DATACENTER_BIT);
|
||||
private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
|
||||
private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT);
|
||||
|
||||
/**
|
||||
* 每一部分向左的位移
|
||||
*/
|
||||
private final static long MACHINE_LEFT = SEQUENCE_BIT;
|
||||
private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
|
||||
private final static long TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT;
|
||||
|
||||
private long datacenterId; //数据中心
|
||||
private long machineId; //机器标识
|
||||
private long sequence = 0L; //序列号
|
||||
private long lastStmp = -1L;//上一次时间戳
|
||||
|
||||
public SnowFlake(long datacenterId, long machineId) {
|
||||
if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) {
|
||||
throw new IllegalArgumentException("datacenterId can't be greater than MAX_DATACENTER_NUM or less than 0");
|
||||
}
|
||||
if (machineId > MAX_MACHINE_NUM || machineId < 0) {
|
||||
throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0");
|
||||
}
|
||||
this.datacenterId = datacenterId;
|
||||
this.machineId = machineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产生下一个ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
long currStmp = getNewstmp();
|
||||
if (currStmp < lastStmp) {
|
||||
throw new RuntimeException("Clock moved backwards. Refusing to generate id");
|
||||
}
|
||||
|
||||
if (currStmp == lastStmp) {
|
||||
//相同毫秒内,序列号自增
|
||||
sequence = (sequence + 1) & MAX_SEQUENCE;
|
||||
//同一毫秒的序列数已经达到最大
|
||||
if (sequence == 0L) {
|
||||
currStmp = getNextMill();
|
||||
}
|
||||
} else {
|
||||
//不同毫秒内,序列号置为0
|
||||
sequence = 0L;
|
||||
}
|
||||
|
||||
lastStmp = currStmp;
|
||||
|
||||
return (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分
|
||||
| datacenterId << DATACENTER_LEFT //数据中心部分
|
||||
| machineId << MACHINE_LEFT //机器标识部分
|
||||
| sequence; //序列号部分
|
||||
}
|
||||
|
||||
private long getNextMill() {
|
||||
long mill = getNewstmp();
|
||||
while (mill <= lastStmp) {
|
||||
mill = getNewstmp();
|
||||
}
|
||||
return mill;
|
||||
}
|
||||
|
||||
private long getNewstmp() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -12,7 +13,7 @@ import static io.dataease.constant.StaticResourceConstants.*;
|
||||
|
||||
public class StaticResourceUtils {
|
||||
|
||||
private final static String FILE_BASE_PATH = USER_HOME+ FILE_SEPARATOR+UPLOAD_URL_PREFIX;
|
||||
private final static String FILE_BASE_PATH = USER_HOME + FILE_SEPARATOR + UPLOAD_URL_PREFIX;
|
||||
|
||||
public static String ensureBoth(@NonNull String string, @NonNull String bothfix) {
|
||||
return ensureBoth(string, bothfix, bothfix);
|
||||
@ -53,8 +54,7 @@ public class StaticResourceUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param imgFile local storage path
|
||||
* @param imgFile local storage path
|
||||
* @return
|
||||
*/
|
||||
public static String getImgFileToBase64(String imgFile) {
|
||||
@ -63,7 +63,7 @@ public class StaticResourceUtils {
|
||||
byte[] buffer = null;
|
||||
//Read picture byte array
|
||||
try {
|
||||
inputStream = new FileInputStream(FILE_BASE_PATH+FILE_SEPARATOR+imgFile);
|
||||
inputStream = new FileInputStream(FILE_BASE_PATH + FILE_SEPARATOR + imgFile);
|
||||
int count = 0;
|
||||
while (count == 0) {
|
||||
count = inputStream.available();
|
||||
@ -72,9 +72,9 @@ public class StaticResourceUtils {
|
||||
inputStream.read(buffer);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}finally {
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
// Close InputStream
|
||||
@ -85,10 +85,9 @@ public class StaticResourceUtils {
|
||||
}
|
||||
}
|
||||
// Encode byte array as Base64
|
||||
if(buffer!=null){
|
||||
|
||||
return Base64Encoder.encode(buffer);
|
||||
}else{
|
||||
if (buffer != null) {
|
||||
return Base64Utils.encodeToString(buffer);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import io.dataease.constant.XpackSettingConstants;
|
||||
|
||||
import java.util.List;
|
||||
@ -8,7 +7,8 @@ import java.util.List;
|
||||
public class SystemSettingUtils {
|
||||
|
||||
public static boolean xpackSetting(String pkey) {
|
||||
List<String> xpackSettingList = ListUtil.toList(XpackSettingConstants.AUTO_CREATE_USER);
|
||||
|
||||
List<String> xpackSettingList = List.of(XpackSettingConstants.AUTO_CREATE_USER);
|
||||
return xpackSettingList.contains(pkey);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import io.dataease.model.ITreeBase;
|
||||
import io.dataease.model.TreeBaseModel;
|
||||
import io.dataease.model.TreeModel;
|
||||
import io.dataease.model.TreeResultModel;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -38,21 +36,21 @@ public class TreeUtils {
|
||||
List<Long> existedList = new ArrayList<>();
|
||||
modelList.forEach(po -> {
|
||||
List<TreeModel> children = null;
|
||||
if (CollectionUtil.isNotEmpty(children = childMap.get(po.getId()))) {
|
||||
if (CollectionUtils.isNotEmpty(children = childMap.get(po.getId()))) {
|
||||
po.setChildren(children);
|
||||
existedList.addAll(children.stream().map(TreeModel::getId).toList());
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isEmpty(modelList)) {
|
||||
if (CollectionUtils.isEmpty(modelList)) {
|
||||
return null;
|
||||
}
|
||||
List<TreeModel> floatingList = modelList.stream().filter(node -> !isRoot(node) && !existedList.contains(node.getId())).toList();
|
||||
if (CollectionUtil.isNotEmpty(existedList)) {
|
||||
if (CollectionUtils.isNotEmpty(existedList)) {
|
||||
modelResult = modelList.stream().filter(node -> !existedList.contains(node.getId())).toList();
|
||||
} else {
|
||||
modelResult = modelList;
|
||||
}
|
||||
if (rootExist.get() && CollectionUtil.isNotEmpty(floatingList)) {
|
||||
if (rootExist.get() && CollectionUtils.isNotEmpty(floatingList)) {
|
||||
modelResult = modelResult.stream().filter(TreeUtils::isRoot).collect(Collectors.toList());
|
||||
TreeModel root = modelResult.get(0);
|
||||
if (root.getChildren() == null) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.dataease.utils;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import io.dataease.constant.AuthConstant;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -8,7 +7,7 @@ import java.util.List;
|
||||
|
||||
public class WhitelistUtils {
|
||||
|
||||
public static List<String> WHITE_PATH = ListUtil.of(
|
||||
public static List<String> WHITE_PATH = List.of(
|
||||
"/login/localLogin",
|
||||
"/apisix/check",
|
||||
"/dekey",
|
||||
|
Loading…
Reference in New Issue
Block a user