From 9408fcd0c8022b4b70884cf2f99bc8430f76fc39 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 22 May 2023 17:09:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=84=B1=E6=95=8F=E8=A7=84=E5=88=99?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/chart/util/ChartDataBuild.java | 18 +++++++++++++++--- .../service/dataset/PermissionService.java | 5 ++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java index 88646f5326..4df9247e53 100644 --- a/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java +++ b/backend/src/main/java/io/dataease/service/chart/util/ChartDataBuild.java @@ -1,8 +1,8 @@ package io.dataease.service.chart.util; import cn.hutool.core.util.ArrayUtil; -import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.dto.chart.*; +import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO; import io.dataease.plugins.xpack.auth.dto.request.ColumnPermissionItem; import org.apache.commons.collections4.CollectionUtils; @@ -1071,11 +1071,11 @@ public class ChartDataBuild { break; } if (originStr.length() >= columnPermissionItem.getDesensitizationRule().getM() && originStr.length() >= columnPermissionItem.getDesensitizationRule().getN()) { - desensitizationStr = "***" + StringUtils.substring(originStr, columnPermissionItem.getDesensitizationRule().getM() - 1, columnPermissionItem.getDesensitizationRule().getN()) + "***"; + desensitizationStr = buildPrefix(columnPermissionItem.getDesensitizationRule().getM()) + StringUtils.substring(originStr, columnPermissionItem.getDesensitizationRule().getM() - 1, columnPermissionItem.getDesensitizationRule().getN()) + "***"; break; } if (originStr.length() >= columnPermissionItem.getDesensitizationRule().getM() && originStr.length() < columnPermissionItem.getDesensitizationRule().getN()) { - desensitizationStr = "***" + StringUtils.substring(originStr, columnPermissionItem.getDesensitizationRule().getM() - 1, originStr.length()); + desensitizationStr = buildPrefix(columnPermissionItem.getDesensitizationRule().getM()) + StringUtils.substring(originStr, columnPermissionItem.getDesensitizationRule().getM() - 1, originStr.length()); } break; default: @@ -1086,6 +1086,18 @@ public class ChartDataBuild { return desensitizationStr; } + + private static String buildPrefix(Integer integer) { + String prefix = ""; + if (integer <= 1) { + return prefix; + } + for (int i = 0; i < integer - 1; i++) { + prefix = prefix + "*"; + } + return prefix; + } + private static Map transTableNormal(List fields, ChartViewWithBLOBs view, List data, Map desensitizationList) { Map map = new TreeMap<>(); List> tableRow = new ArrayList<>(); diff --git a/backend/src/main/java/io/dataease/service/dataset/PermissionService.java b/backend/src/main/java/io/dataease/service/dataset/PermissionService.java index 77fba010d0..9199b275ea 100644 --- a/backend/src/main/java/io/dataease/service/dataset/PermissionService.java +++ b/backend/src/main/java/io/dataease/service/dataset/PermissionService.java @@ -208,7 +208,10 @@ public class PermissionService { dataSetColumnPermissionsDTO.setDatasetId(datasetId); dataSetColumnPermissionsDTO.setAuthTargetIds(Collections.singletonList(userId)); dataSetColumnPermissionsDTO.setAuthTargetType("user"); - datasetColumnPermissions.addAll(columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO)); + List dataSetColumnPermissionsDTOS = columnPermissionService.searchPermissions(dataSetColumnPermissionsDTO); + if(CollectionUtils.isNotEmpty(dataSetColumnPermissionsDTOS)){ + datasetColumnPermissions.addAll(dataSetColumnPermissionsDTOS); + } if (CollectionUtils.isNotEmpty(roleIds)) { DataSetColumnPermissionsDTO request = new DataSetColumnPermissionsDTO(); request.setDatasetId(datasetId);