fix: 行权限枚举值

This commit is contained in:
taojinlong 2022-05-31 19:03:27 +08:00
parent 482036726b
commit 8aa0bf2153
3 changed files with 18 additions and 18 deletions

View File

@ -159,7 +159,7 @@ public class DataSetTableFieldController {
public List<Object> multFieldValues(@RequestBody MultFieldValuesRequest multFieldValuesRequest) throws Exception {
List<Object> results = new ArrayList<>();
for (String fieldId : multFieldValuesRequest.getFieldIds()) {
List<Object> fieldValues = dataSetFieldService.fieldValues(fieldId, multFieldValuesRequest.getUserId(), true);
List<Object> fieldValues = dataSetFieldService.fieldValues(fieldId, multFieldValuesRequest.getUserId(), true, false);
if (CollectionUtil.isNotEmpty(fieldValues)) {
results.addAll(fieldValues);
}
@ -185,13 +185,13 @@ public class DataSetTableFieldController {
DecodedJWT jwt = JWT.decode(linkToken);
Long userId = jwt.getClaim("userId").asLong();
multFieldValuesRequest.setUserId(userId);
return dataSetFieldService.fieldValues(multFieldValuesRequest.getFieldIds(), multFieldValuesRequest.getUserId(), true, true);
return dataSetFieldService.fieldValues(multFieldValuesRequest.getFieldIds(), multFieldValuesRequest.getUserId(), true, true,false);
}
@ApiIgnore
@PostMapping("mappingFieldValues")
public List<Object> mappingFieldValues(@RequestBody MultFieldValuesRequest multFieldValuesRequest) throws Exception {
return dataSetFieldService.fieldValues(multFieldValuesRequest.getFieldIds(), multFieldValuesRequest.getUserId(), true, true);
return dataSetFieldService.fieldValues(multFieldValuesRequest.getFieldIds(), multFieldValuesRequest.getUserId(), true, true, false);
}
@ApiIgnore
@ -199,7 +199,7 @@ public class DataSetTableFieldController {
public List<Object> multFieldValuesForPermissions(@RequestBody MultFieldValuesRequest multFieldValuesRequest) throws Exception {
List<Object> results = new ArrayList<>();
for (String fieldId : multFieldValuesRequest.getFieldIds()) {
List<Object> fieldValues = dataSetFieldService.fieldValues(fieldId, multFieldValuesRequest.getUserId(), false);
List<Object> fieldValues = dataSetFieldService.fieldValues(fieldId, multFieldValuesRequest.getUserId(), false, true);
if (CollectionUtil.isNotEmpty(fieldValues)) {
results.addAll(fieldValues);
}

View File

@ -5,7 +5,7 @@ import java.util.List;
public interface DataSetFieldService {
List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions) throws Exception;
List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions, Boolean rowAndColumnMgm) throws Exception;
List<Object> fieldValues(List<String> fieldIds, Long userId, Boolean userPermissions, Boolean needMapping) throws Exception;
List<Object> fieldValues(List<String> fieldIds, Long userId, Boolean userPermissions, Boolean needMapping, Boolean rowAndColumnMgm) throws Exception;
}

View File

@ -45,14 +45,14 @@ public class DirectFieldService implements DataSetFieldService {
private EngineService engineService;
@Override
public List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions) throws Exception {
public List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions, Boolean rowAndColumnMgm) throws Exception {
List<String> filedIds = new ArrayList<>();
filedIds.add(fieldId);
return fieldValues(filedIds, userId, userPermissions, false);
return fieldValues(filedIds, userId, userPermissions, false, rowAndColumnMgm);
}
@Override
public List<Object> fieldValues(List<String> fieldIds, Long userId, Boolean userPermissions, Boolean needMapping) throws Exception {
public List<Object> fieldValues(List<String> fieldIds, Long userId, Boolean userPermissions, Boolean needMapping, Boolean rowAndColumnMgm) throws Exception {
String fieldId = fieldIds.get(0);
DatasetTableField field = dataSetTableFieldsService.selectByPrimaryKey(fieldId);
if (field == null || StringUtils.isEmpty(field.getTableId())) return null;
@ -70,22 +70,15 @@ public class DirectFieldService implements DataSetFieldService {
List<DatasetTableField> permissionFields = fields;
List<ChartFieldCustomFilterDTO> customFilter = new ArrayList<>();
if(userPermissions){
if (userPermissions) {
//列权限
List<String> desensitizationList = new ArrayList<>();
fields = permissionService.filterColumnPermissons(fields, desensitizationList, datasetTable.getId(), userId);
Map<String, DatasetTableField> fieldMap = fields.stream().collect(Collectors.toMap(DatasetTableField::getId, node -> node));
permissionFields = fieldIds.stream().map(fieldMap::get).collect(Collectors.toList());
//permissionFields = fields.stream().filter(node -> fieldIds.stream().anyMatch(item -> StringUtils.equals(node.getId(), item))).collect(Collectors.toList());
if (CollectionUtils.isEmpty(permissionFields)) {
return new ArrayList<>();
}
//禁用的
/*if(!fields.stream().map(DatasetTableField::getId).collect(Collectors.toList()).contains(fieldId)){
return new ArrayList<>();
}*/
if (CollectionUtils.isNotEmpty(desensitizationList) && desensitizationList.contains(field.getDataeaseName())) {
List<Object> results = new ArrayList<>();
results.add(ColumnPermissionConstants.Desensitization_desc);
@ -94,6 +87,13 @@ public class DirectFieldService implements DataSetFieldService {
//行权限
customFilter = permissionService.getCustomFilters(fields, datasetTable, userId);
}
if (rowAndColumnMgm) {
Map<String, DatasetTableField> fieldMap = fields.stream().collect(Collectors.toMap(DatasetTableField::getId, node -> node));
permissionFields = fieldIds.stream().map(fieldMap::get).collect(Collectors.toList());
if (CollectionUtils.isEmpty(permissionFields)) {
return new ArrayList<>();
}
}
DatasourceRequest datasourceRequest = new DatasourceRequest();
Provider datasourceProvider = null;
@ -148,7 +148,7 @@ public class DirectFieldService implements DataSetFieldService {
}
private List<BaseTreeNode> buildTreeNode(String [] row, Set<String> pkSet) {
private List<BaseTreeNode> buildTreeNode(String[] row, Set<String> pkSet) {
List<BaseTreeNode> nodes = new ArrayList<>();
List<String> parentPkList = new ArrayList<>();
for (int i = 0; i < row.length; i++) {