diff --git a/core/core-backend/src/main/java/io/dataease/dataset/manage/PermissionManage.java b/core/core-backend/src/main/java/io/dataease/dataset/manage/PermissionManage.java index 78a7019ece..f05831e89b 100644 --- a/core/core-backend/src/main/java/io/dataease/dataset/manage/PermissionManage.java +++ b/core/core-backend/src/main/java/io/dataease/dataset/manage/PermissionManage.java @@ -23,10 +23,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.lang.reflect.Array; +import java.util.*; import java.util.stream.Collectors; @Service @@ -211,7 +209,7 @@ public class PermissionManage { continue; } - String value = handleSysVariable(userEntity, datasetRowPermissionsTreeItem.getValue()); + String value = handleSysVariable(userEntity, datasetRowPermissionsTreeItem); if (value == null) { continue; } else { @@ -227,28 +225,35 @@ public class PermissionManage { return result; } - private String handleSysVariable(UserFormVO userEntity, String sysVariable) { + private String handleSysVariable(UserFormVO userEntity, DatasetRowPermissionsTreeItem datasetRowPermissionsTreeItem) { String value = null; - if (StringUtils.isNotBlank(sysVariable) && sysVariable.startsWith("${") && sysVariable.endsWith("}")) { - String variableId = sysVariable.substring(2, sysVariable.length() - 1); - for (SysVariableValueItem variable : userEntity.getVariables()) { - if (!variable.isValid()){ - continue; - } - if (variableId.equalsIgnoreCase(variable.getVariableId().toString())) { - if (variable.getSysVariableDto().getType().equalsIgnoreCase("text")) { - for (SysVariableValueDto sysVariableValueDto : variable.getValueList()) { - if (sysVariableValueDto.getId().equals(variable.getVariableValueId())) { - value = sysVariableValueDto.getValue(); - } + String sysVariable = datasetRowPermissionsTreeItem.getValue(); + if (StringUtils.isEmpty(sysVariable) && !(sysVariable.startsWith("${") && sysVariable.endsWith("}"))) { + return value; + } + String variableId = sysVariable.substring(2, sysVariable.length() - 1); + for (SysVariableValueItem variable : userEntity.getVariables()) { + if (!variable.isValid()) { + continue; + } + if (!variableId.equalsIgnoreCase(variable.getVariableId().toString())) { + continue; + } + if (variable.getSysVariableDto().getType().equalsIgnoreCase("text")) { + if (Arrays.asList("in", "not in").contains(datasetRowPermissionsTreeItem.getTerm())) { + value = String.join(",", variable.getValueList().stream().filter(sysVariableValueDto -> variable.getVariableValueIds().contains(sysVariableValueDto.getId().toString())).map(SysVariableValueDto::getValue).collect(Collectors.toList())); + } else { + for (SysVariableValueDto sysVariableValueDto : variable.getValueList()) { + if (sysVariableValueDto.getId().equals(variable.getVariableValueId())) { + value = sysVariableValueDto.getValue(); } - } else { - value = variable.getVariableValue(); } - } + } else { + value = variable.getVariableValue(); } } + return value; } diff --git a/sdk/api/api-permissions/src/main/java/io/dataease/api/permissions/variable/dto/SysVariableValueItem.java b/sdk/api/api-permissions/src/main/java/io/dataease/api/permissions/variable/dto/SysVariableValueItem.java index 2bf18eb150..15b2d1e640 100644 --- a/sdk/api/api-permissions/src/main/java/io/dataease/api/permissions/variable/dto/SysVariableValueItem.java +++ b/sdk/api/api-permissions/src/main/java/io/dataease/api/permissions/variable/dto/SysVariableValueItem.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; +import java.util.ArrayList; import java.util.List; @Data @@ -14,8 +15,9 @@ public class SysVariableValueItem { private String variableType; @JsonSerialize(using = ToStringSerializer.class) private Long variableId; + private List variableValueIds = new ArrayList<>(); @JsonSerialize(using = ToStringSerializer.class) - private Long variableValueId; + private Long variableValueId ; private String variableName; private boolean valid = true; private List valueList;