use of com.albedo.java.modules.sys.domain.RoleDeptDo in project albedo by somowhere.
the class RoleServiceImpl method saveOrUpdate.
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(RoleDto roleDto) {
boolean add = ObjectUtil.isEmpty(roleDto.getId());
super.saveOrUpdate(roleDto);
if (CollUtil.isNotEmpty(roleDto.getMenuIdList())) {
roleMenuService.remove(Wrappers.<RoleMenuDo>query().lambda().eq(RoleMenuDo::getRoleId, roleDto.getId()));
List<RoleMenuDo> roleMenuDoList = roleDto.getMenuIdList().stream().map(menuId -> {
RoleMenuDo roleMenuDo = new RoleMenuDo();
roleMenuDo.setRoleId(roleDto.getId());
roleMenuDo.setMenuId(menuId);
return roleMenuDo;
}).collect(Collectors.toList());
roleMenuService.saveBatch(roleMenuDoList);
}
if (CollUtil.isNotEmpty(roleDto.getDeptIdList())) {
roleDeptService.remove(Wrappers.<RoleDeptDo>query().lambda().eq(RoleDeptDo::getRoleId, roleDto.getId()));
List<RoleDeptDo> roleDeptDoList = roleDto.getDeptIdList().stream().map(deptId -> {
RoleDeptDo roleDeptDo = new RoleDeptDo();
roleDeptDo.setRoleId(roleDto.getId());
roleDeptDo.setDeptId(deptId);
return roleDeptDo;
}).collect(Collectors.toList());
roleDeptService.saveBatch(roleDeptDoList);
}
// 清空userinfo
if (!add) {
SysCacheUtil.delRoleCaches(roleDto.getId());
}
}
Aggregations