use of com.diboot.iam.entity.IamResourcePermission in project diboot by dibo-software.
the class IamResourcePermissionServiceImpl method hasDirtyData.
/**
* 检测是否又脏数据存在
* @return
*/
private boolean hasDirtyData() {
List<IamResourcePermission> list = this.getEntityList(null);
if (V.isEmpty(list)) {
return false;
}
Map<String, IamResourcePermission> idObjectMap = BeanUtils.convertToStringKeyObjectMap(list, BeanUtils.convertToFieldName(IamResourcePermission::getId));
List<Long> deleteIdList = new ArrayList<>();
for (IamResourcePermission item : list) {
if (!hasTopRootNode(idObjectMap, item, null)) {
deleteIdList.add(item.getId());
}
}
return V.notEmpty(deleteIdList);
}
use of com.diboot.iam.entity.IamResourcePermission in project diboot by dibo-software.
the class IamResourcePermissionServiceImpl method clearDirtyData.
/**
* 清理没有关联关系的
*/
private void clearDirtyData() {
List<IamResourcePermission> list = this.getEntityList(null);
if (V.isEmpty(list)) {
return;
}
Map<String, IamResourcePermission> idObjectMap = BeanUtils.convertToStringKeyObjectMap(list, BeanUtils.convertToFieldName(IamResourcePermission::getId));
List<Long> deleteIdList = new ArrayList<>();
for (IamResourcePermission item : list) {
if (!hasTopRootNode(idObjectMap, item, null)) {
deleteIdList.add(item.getId());
}
}
if (V.notEmpty(deleteIdList)) {
LambdaQueryWrapper deleteWrapper = Wrappers.<IamResourcePermission>lambdaQuery().in(IamResourcePermission::getId, deleteIdList);
long count = this.getEntityListCount(deleteWrapper);
if (count > 0) {
this.deleteEntities(deleteWrapper);
log.info("共清理掉{}条无用数据", count);
}
}
}
use of com.diboot.iam.entity.IamResourcePermission in project diboot by dibo-software.
the class IamHelper method buildRoleVo4FrontEnd.
/**
* 构建role-permission角色权限数据格式(合并role等),用于前端适配
* @param roleVOList
* @return
*/
public static IamRoleVO buildRoleVo4FrontEnd(List<IamRoleVO> roleVOList) {
if (V.isEmpty(roleVOList)) {
return null;
}
// 对RoleList做聚合处理,以适配前端
List<String> nameList = new ArrayList<>(roleVOList.size());
List<String> codeList = new ArrayList<>(roleVOList.size());
List<IamResourcePermission> allPermissionList = new ArrayList<>();
roleVOList.forEach(vo -> {
nameList.add(vo.getName());
codeList.add(vo.getCode());
if (V.notEmpty(vo.getPermissionList())) {
allPermissionList.addAll(vo.getPermissionList());
}
});
// 对permissionList进行去重
List permissionList = BeanUtils.distinctByKey(allPermissionList, IamResourcePermission::getId);
IamRoleVO roleVO = new IamRoleVO();
roleVO.setName(S.join(nameList));
roleVO.setCode(S.join(codeList));
roleVO.setPermissionList(permissionList);
return roleVO;
}
Aggregations