| | |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.domain.dto.RoleAddDto; |
| | | import com.ruoyi.system.domain.dto.RoleQuery; |
| | | import com.ruoyi.system.domain.dto.RoleUpdateDto; |
| | | import com.ruoyi.system.domain.vo.RoleInfoVo; |
| | | import com.ruoyi.system.mapper.SysMenuMapper; |
| | |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.seata.common.util.StringUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | } |
| | | |
| | | |
| | | // @ApiOperation("获取所有角色信息根据公司id--分页") |
| | | @GetMapping("/listPage") |
| | | public AjaxResult listPage(Integer companyId,int pageNumber,int pageSize) |
| | | @ApiOperation("获取角色列表") |
| | | @PostMapping("/listPage") |
| | | public AjaxResult listPage(@Validated @RequestBody RoleQuery query) |
| | | { |
| | | PageInfo<SysRole> pageInfo = new PageInfo<>(pageNumber, pageSize); |
| | | PageInfo<SysRole> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | |
| | | PageInfo<SysRole> page = roleService.page(pageInfo, |
| | | new LambdaQueryWrapper<SysRole>().ne(SysRole::getRoleId, 20)); |
| | | new LambdaQueryWrapper<SysRole>().ne(SysRole::getRoleId, 20) |
| | | .like(StringUtils.isNotBlank(query.getRoleName()), SysRole::getRoleName, |
| | | query.getRoleName()).eq(SysRole::getDelFlag, "0")); |
| | | return AjaxResult.success(page); |
| | | } |
| | | |
| | |
| | | public AjaxResult roleInfoFromUserId( @RequestParam Long userId) |
| | | { |
| | | SysUserRole one = sysUserRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId)); |
| | | if (Objects.isNull(one)) { |
| | | return AjaxResult.success(); |
| | | } |
| | | Long id =one.getRoleId(); |
| | | // 获取当前角色的菜单id |
| | | List<Long> menusId = sysRoleMenuMapper.selectList(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, id)).stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()); |
| | | if(menusId.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | if(id!=1){ |
| | | menusId = menusId.stream().filter(e->e!=1074 && e!=1075 && e!=1193 && e!=1194).collect(Collectors.toList()); |
| | | } |
| | | //获取当前的权限菜单 |
| | | List<SysMenus> all = menuMapper.getAllInIds(menusId); |
| | | List<SysMenus> allUser = menuMapper.getAllInIds(menusId); |
| | | // 查询所有权限菜单 |
| | | List<SysMenus> all = menuMapper.getAll(); |
| | | // 创建一个Map来存储all集合中的menuId |
| | | Map<Long, Boolean> menuIdExistMap = allUser.stream() |
| | | .collect(Collectors.toMap(SysMenus::getMenuId, aMenu -> true, |
| | | (oldValue, newValue) -> oldValue)); |
| | | |
| | | // 遍历allUser集合,根据menuIdExistMap来设置isHave值 |
| | | for (SysMenus allMenu : all) { |
| | | allMenu.setIsHave(menuIdExistMap.containsKey(allMenu.getMenuId()) ? 1 : 2); |
| | | } |
| | | |
| | | // 第三级 |
| | | List<SysMenus> s3 = all.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); |
| | | // 第二级 |
| | |
| | | |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation("删除角色") |
| | | @DeleteMapping("/{id}") |
| | | @DeleteMapping("/del/{id}") |
| | | public AjaxResult removeRole( |
| | | @ApiParam(name = "id", value = "角色ID", required = true) @PathVariable Long id) { |
| | | roleService.removeRole(id); |