| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysRoleServiceImpl implements ISysRoleService { |
| | | public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements |
| | | ISysRoleService { |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | |
| | | // 添加角色 |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setRoleName(dto.getRoleName()); |
| | | sysRole.setRoleKey("admin"); |
| | | roleMapper.insertRole(sysRole); |
| | | |
| | | // 添加角色权限中间表 |
| | |
| | | |
| | | return roleMenuMapper.batchRoleMenu(sysRoleMenus); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysMenu> getMenuByRoleId(Long roleId) { |
| | | SysRole sysRole = roleMapper.selectRoleById(roleId); |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuMapper.selectListByRoleId(sysRole.getRoleId()); |
| | | if (menus.size() == 0) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | // 获取当前的权限菜单(有层级) |
| | | return this.getMenuLevelList(menusId); |
| | | } |
| | | } |