|
@@ -187,20 +187,23 @@ public class DataAuthServiceImpl implements IDataAuthService {
|
|
|
@Override
|
|
|
public boolean subDataAuthAdd(SubDataAuthDTO subDataAuthDTO) {
|
|
|
List<SubDataDTO> subDataList = subDataAuthDTO.getDataAuthList();
|
|
|
- if (CollectionUtils.isEmpty(subDataList)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ //过滤哪些权限需要删除,哪些权限需要新增
|
|
|
+ Date date = new Date();
|
|
|
+ String subId = subDataAuthDTO.getSubId();
|
|
|
+ String subType = subDataAuthDTO.getSubType();
|
|
|
+ String authType = subDataAuthDTO.getAuthType();
|
|
|
String userId = null;
|
|
|
BaseSecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
if (null != currentUser) {
|
|
|
userId = currentUser.getId();
|
|
|
}
|
|
|
- Date date = new Date();
|
|
|
- String subId = subDataAuthDTO.getSubId();
|
|
|
- String subType = subDataAuthDTO.getSubType();
|
|
|
- String authType = subDataAuthDTO.getAuthType();
|
|
|
- //过滤哪些权限需要删除,哪些权限需要新增
|
|
|
+ //传入权限为空时
|
|
|
+ //删除该主体下所有的权限
|
|
|
List<DataAuth> existDataAuths = getDataAuthsBySub(subId, subType, authType);
|
|
|
+ if (CollectionUtils.isEmpty(subDataList)) {
|
|
|
+ delDataAuthList(date, userId, existDataAuths);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
Set<String> existSet = existDataAuths.stream()
|
|
|
.map(item -> item.getDataId() + ";" + item.getDataType())
|
|
|
.collect(Collectors.toSet());
|
|
@@ -213,6 +216,16 @@ public class DataAuthServiceImpl implements IDataAuthService {
|
|
|
List<SubDataDTO> addList = subDataList.stream()
|
|
|
.filter(item -> addCollect.contains(item.getDataId() + ";" + item.getDataType()))
|
|
|
.collect(Collectors.toList());
|
|
|
+ addDataAuthList(date, subId, subType, authType, userId, addList);
|
|
|
+ //删除
|
|
|
+ List<DataAuth> delList = existDataAuths.stream()
|
|
|
+ .filter(item -> delCollect.contains(item.getDataId() + ";" + item.getDataType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ delDataAuthList(date, userId, delList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addDataAuthList(Date date, String subId, String subType, String authType, String userId, List<SubDataDTO> addList) {
|
|
|
for (SubDataDTO dto : addList) {
|
|
|
DataAuth dataAuth = new DataAuth();
|
|
|
dataAuth.setDataCode(dto.getDataCode());
|
|
@@ -227,17 +240,15 @@ public class DataAuthServiceImpl implements IDataAuthService {
|
|
|
dataAuth.setDeleted(YesNotEnum.NO.getValue());
|
|
|
dataAuthBPO.save(dataAuth);
|
|
|
}
|
|
|
- //删除
|
|
|
- List<DataAuth> delList = existDataAuths.stream()
|
|
|
- .filter(item -> delCollect.contains(item.getDataId() + ";" + item.getDataType()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void delDataAuthList(Date date, String userId, List<DataAuth> delList) {
|
|
|
for (DataAuth dataAuth : delList) {
|
|
|
dataAuth.setDeleteUser(userId);
|
|
|
dataAuth.setDeleteTime(date);
|
|
|
dataAuth.setDeleted(BooleanEnum.TRUE.getValue());
|
|
|
dataAuthBPO.update(dataAuth);
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
|
|
|
@Override
|