use of com.albedo.java.modules.sys.domain.RoleMenuDo in project albedo by somowhere.
the class RoleMenuServiceImpl method saveRoleMenus.
/**
* @param roleMenuDto 角色菜单
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result saveRoleMenus(RoleMenuDto roleMenuDto) {
this.remove(Wrappers.<RoleMenuDo>query().lambda().eq(RoleMenuDo::getRoleId, roleMenuDto.getRoleId()));
List<RoleMenuDo> roleMenuDoList = roleMenuDto.getMenuIdList().stream().map(menuId -> {
RoleMenuDo roleMenuDo = new RoleMenuDo();
roleMenuDo.setRoleId(roleMenuDto.getRoleId());
roleMenuDo.setMenuId(menuId);
return roleMenuDo;
}).collect(Collectors.toList());
this.saveBatch(roleMenuDoList);
SysCacheUtil.delRoleCaches(roleMenuDto.getRoleId());
return Result.buildOk("操作成功");
}
use of com.albedo.java.modules.sys.domain.RoleMenuDo 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());
}
}
use of com.albedo.java.modules.sys.domain.RoleMenuDo in project albedo by somowhere.
the class MenuServiceImpl method saveByGenScheme.
@Override
public boolean saveByGenScheme(GenSchemeDto schemeDto) {
String moduleName = schemeDto.getSchemeName(), parentMenuId = schemeDto.getParentMenuId(), url = schemeDto.getUrl();
String permission = StringUtil.toCamelCase(StringUtil.lowerFirst(url), CharUtil.DASHED).replace(StringUtil.SLASH, "_").substring(1), permissionLike = permission.substring(0, permission.length() - 1);
List<MenuDo> currentMenuListDo = repository.selectList(Wrappers.<MenuDo>query().lambda().eq(MenuDo::getName, moduleName).or().likeLeft(MenuDo::getPermission, permissionLike));
for (MenuDo currentMenuDo : currentMenuListDo) {
if (currentMenuDo != null) {
List<Long> idList = repository.selectList(Wrappers.<MenuDo>query().lambda().likeLeft(MenuDo::getPermission, permissionLike).or(i -> i.eq(MenuDo::getId, currentMenuDo.getId()).or().eq(MenuDo::getParentId, currentMenuDo.getId()))).stream().map(MenuDo::getId).collect(Collectors.toList());
roleMenuRepository.delete(Wrappers.<RoleMenuDo>query().lambda().in(RoleMenuDo::getMenuId, idList));
repository.deleteBatchIds(idList);
}
}
MenuDo parentMenuDo = repository.selectById(parentMenuId);
ArgumentAssert.notNull(parentMenuDo, StringUtil.toAppendStr("根据模块id[", parentMenuId, "无法查询到模块信息]"));
MenuDo module = new MenuDo();
module.setName(moduleName);
module.setParentId(parentMenuDo.getId());
module.setType(MenuDo.TYPE_MENU);
module.setIcon("app");
module.setPath(StringUtil.toRevertCamelCase(StringUtil.lowerFirst(schemeDto.getClassName()), CharUtil.DASHED));
module.setComponent(url.substring(1) + "index");
save(module);
MenuDo moduleView = new MenuDo();
moduleView.setParent(module);
moduleView.setName(moduleName + "查看");
moduleView.setPermission(permission + "view");
moduleView.setParentId(module.getId());
moduleView.setType(MenuDo.TYPE_BUTTON);
moduleView.setSort(20);
save(moduleView);
MenuDo moduleEdit = new MenuDo();
moduleEdit.setParent(module);
moduleEdit.setName(moduleName + "编辑");
moduleEdit.setPermission(permission + "edit");
moduleEdit.setParentId(module.getId());
moduleEdit.setType(MenuDo.TYPE_BUTTON);
moduleEdit.setSort(40);
save(moduleEdit);
MenuDo moduleDelete = new MenuDo();
moduleDelete.setParent(module);
moduleDelete.setName(moduleName + "删除");
moduleDelete.setPermission(permission + "del");
moduleDelete.setParentId(module.getId());
moduleDelete.setType(MenuDo.TYPE_BUTTON);
moduleDelete.setSort(80);
save(moduleDelete);
return true;
}
use of com.albedo.java.modules.sys.domain.RoleMenuDo in project albedo by somowhere.
the class MenuServiceImpl method removeByIds.
@Override
public void removeByIds(Set<Long> ids) {
ids.forEach(id -> {
SysCacheUtil.delMenuCaches(id);
// 查询父节点为当前节点的节点
List<MenuDo> menuDoList = this.list(Wrappers.<MenuDo>query().lambda().eq(MenuDo::getParentId, id));
ArgumentAssert.notEmpty(menuDoList, () -> new BizException("菜单含有下级不能删除"));
roleMenuRepository.delete(Wrappers.<RoleMenuDo>query().lambda().eq(RoleMenuDo::getMenuId, id));
// 删除当前菜单及其子菜单
this.removeById(id);
});
}
use of com.albedo.java.modules.sys.domain.RoleMenuDo in project albedo by somowhere.
the class RoleServiceImpl method getOneDto.
@Override
public RoleDto getOneDto(Serializable id) {
RoleDto oneVo = super.getOneDto(id);
oneVo.setMenuIdList(roleMenuService.list(Wrappers.<RoleMenuDo>query().lambda().eq(RoleMenuDo::getRoleId, id)).stream().map(RoleMenuDo::getMenuId).collect(Collectors.toList()));
oneVo.setDeptIdList(findDeptIdsByRoleId(id));
return oneVo;
}
Aggregations