com.ruoyi.system.domain.SysRole Java Examples
The following examples show how to use
com.ruoyi.system.domain.SysRole.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 根据角色ID查询部门(数据权限) * * @param role 角色对象 * @return 部门列表(数据权限) */ @Override public List<Map<String, Object>> roleDeptTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<SysDept> deptList = selectDeptList(new SysDept()); if (StringUtils.isNotNull(roleId)) { List<String> roleDeptList = deptMapper.selectRoleDeptTree(roleId); trees = getTrees(deptList, true, roleDeptList); } else { trees = getTrees(deptList, false, null); } return trees; }
Example #2
Source File: SysRoleServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 新增角色菜单信息 * * @param role 角色对象 */ public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; }
Example #3
Source File: SysRoleServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 根据用户ID查询角色 * * @param userId 用户ID * @return 角色列表 */ @Override public List<SysRole> selectRolesByUserId(Long userId) { List<SysRole> userRoles = roleMapper.selectRolesByUserId(userId); List<SysRole> roles = selectRoleAll(); for (SysRole role : roles) { for (SysRole userRole : userRoles) { if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { role.setFlag(true); break; } } } return roles; }
Example #4
Source File: SysRoleServiceImpl.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 新增角色菜单信息 * * @param role 角色对象 */ private int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List<SysRoleMenu> list = new ArrayList<>(); for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } if (!CollectionUtils.isEmpty(list)) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; }
Example #5
Source File: SysRoleController.java From supplierShop with MIT License | 6 votes |
/** * 新增保存角色 */ @RequiresPermissions("system:role:add") @Log(title = "角色管理", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(@Validated SysRole role) { if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setCreateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(roleService.insertRole(role)); }
Example #6
Source File: SysRoleController.java From supplierShop with MIT License | 6 votes |
/** * 修改保存角色 */ @RequiresPermissions("system:role:edit") @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysRole role) { if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setUpdateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(roleService.updateRole(role)); }
Example #7
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 根据角色ID查询菜单 * * @param role 角色对象 * @return 菜单列表 */ @Override public List<Map<String, Object>> roleMenuTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<SysMenu> menuList = menuMapper.selectMenuAll(); if (StringUtils.isNotNull(roleId)) { List<String> roleMenuList = menuMapper.selectMenuTree(roleId); trees = getTrees(menuList, true, roleMenuList, true); } else { trees = getTrees(menuList, false, null, true); } return trees; }
Example #8
Source File: SysRoleServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 新增角色部门信息(数据权限) * * @param role 角色对象 */ public int insertRoleDept(SysRole role) { int rows = 1; // 新增角色与部门(数据权限)管理 List<SysRoleDept> list = new ArrayList<SysRoleDept>(); for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); rd.setDeptId(deptId); list.add(rd); } if (list.size() > 0) { rows = roleDeptMapper.batchRoleDept(list); } return rows; }
Example #9
Source File: SysUserServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 查询用户所属角色组 * * @param userId 用户ID * @return 结果 */ @Override public String selectUserRoleGroup(Long userId) { List<SysRole> list = roleMapper.selectRolesByUserId(userId); StringBuffer idsStr = new StringBuffer(); for (SysRole role : list) { idsStr.append(role.getRoleName()).append(","); } if (StringUtils.isNotEmpty(idsStr.toString())) { return idsStr.substring(0, idsStr.length() - 1); } return idsStr.toString(); }
Example #10
Source File: SysRoleServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 新增角色菜单信息 * * @param role 角色对象 */ public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; }
Example #11
Source File: SysRoleServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 新增保存角色信息 * * @param role 角色信息 * @return 结果 */ @Override public int insertRole(SysRole role) { // 新增角色信息 roleMapper.insertRole(role); return insertRoleMenu(role); }
Example #12
Source File: SysRoleServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 校验角色权限是否唯一 * * @param role 角色信息 * @return 结果 */ @Override public String checkRoleKeyUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.ROLE_KEY_NOT_UNIQUE; } return UserConstants.ROLE_KEY_UNIQUE; }
Example #13
Source File: SysMenuController.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 加载所有菜单列表树 */ @GetMapping("/menuTreeData") @ResponseBody public List<Ztree> menuTreeData(SysRole role) { Long userId = ShiroUtils.getUserId(); return menuService.menuTreeData(userId); }
Example #14
Source File: SysRoleController.java From ruoyiplus with MIT License | 5 votes |
/** * 修改保存数据权限 */ @RequiresPermissions("system:role:edit") @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PostMapping("/rule") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult ruleSave(SysRole role) { role.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(roleService.updateRule(role)); }
Example #15
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
/** * 加载角色部门(数据权限)列表树,适配EleTree */ @GetMapping("/roleDeptTreeData2") @ResponseBody public Map deptTreeData2(SysRole role) { Map retMap = new HashMap(); List<Map<String, Object>> tree = deptService.roleDeptTreeData(role); tree = EleTreeWrapper.getInstance().getTree(tree,"pId","id"); retMap.put("code",0); retMap.put("data",tree); return retMap; }
Example #16
Source File: SysRoleController.java From ruoyiplus with MIT License | 5 votes |
/** * 校验角色名称 */ @PostMapping("/checkRoleNameUnique") @ResponseBody public String checkRoleNameUnique(SysRole role) { return roleService.checkRoleNameUnique(role); }
Example #17
Source File: SysRoleServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 批量删除角色信息 * * @param ids 需要删除的数据ID * @throws Exception */ @Override public int deleteRoleByIds(String ids) throws BusinessException { Long[] roleIds = Convert.toLongArray(ids); for (Long roleId : roleIds) { SysRole role = selectRoleById(roleId); if (countUserRoleByRoleId(roleId) > 0) { throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } return roleMapper.deleteRoleByIds(roleIds); }
Example #18
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 根据角色ID查询部门(数据权限) * * @param role 角色对象 * @return 部门列表(数据权限) */ @Override public List<Ztree> roleDeptTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Ztree> ztrees; List<SysDept> deptList = selectDeptList(new SysDept()); if (ObjectUtil.isNotNull(roleId)) { List<String> roleDeptList = deptMapper.selectRoleDeptTree(roleId); ztrees = initZtree(deptList, roleDeptList); } else { ztrees = initZtree(deptList); } return ztrees; }
Example #19
Source File: SysRoleController.java From ruoyiplus with MIT License | 5 votes |
/** * 角色状态修改 */ @Log(title = "角色管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:role:edit") @PostMapping("/changeStatus") @ResponseBody public AjaxResult changeStatus(SysRole role) { return toAjax(roleService.changeStatus(role)); }
Example #20
Source File: SysRoleController.java From RuoYi with Apache License 2.0 | 5 votes |
@Log(title = "角色管理", businessType = BusinessType.EXPORT) @RequiresPermissions("system:role:export") @PostMapping("/export") @ResponseBody public AjaxResult export(SysRole role) { List<SysRole> list = roleService.selectRoleList(role); ExcelUtil<SysRole> util = new ExcelUtil<>(SysRole.class); return util.exportExcel(list, "角色信息"); }
Example #21
Source File: SysMenuController.java From supplierShop with MIT License | 5 votes |
/** * 加载角色菜单列表树 */ @GetMapping("/roleMenuTreeData") @ResponseBody public List<Ztree> roleMenuTreeData(SysRole role) { Long userId = ShiroUtils.getUserId(); List<Ztree> ztrees = menuService.roleMenuTreeData(role, userId); return ztrees; }
Example #22
Source File: SysRoleController.java From supplierShop with MIT License | 5 votes |
@Log(title = "角色管理", businessType = BusinessType.EXPORT) @RequiresPermissions("system:role:export") @PostMapping("/export") @ResponseBody public AjaxResult export(SysRole role) { List<SysRole> list = roleService.selectRoleList(role); ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); return util.exportExcel(list, "角色数据"); }
Example #23
Source File: SysRoleController.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 角色状态修改 */ @Log(title = "角色管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:role:edit") @PostMapping("/changeStatus") @ResponseBody public AjaxResult changeStatus(SysRole role) { return toAjax(roleService.changeStatus(role)); }
Example #24
Source File: SysRoleController.java From supplierShop with MIT License | 5 votes |
/** * 校验角色名称 */ @PostMapping("/checkRoleNameUnique") @ResponseBody public String checkRoleNameUnique(SysRole role) { return roleService.checkRoleNameUnique(role); }
Example #25
Source File: SysMenuController.java From ruoyiplus with MIT License | 5 votes |
@GetMapping("/roleMenuTreeData2") @ResponseBody public Map roleMenuTreeData2(SysRole role) { Map retMap = new HashMap(); List<Map<String, Object>> tree = menuService.roleMenuTreeData(role); tree = EleTreeWrapper.getInstance().getTree(tree,"pId","id"); retMap.put("code",0); retMap.put("data",tree); return retMap; }
Example #26
Source File: SysRoleController.java From supplierShop with MIT License | 5 votes |
/** * 角色状态修改 */ @Log(title = "角色管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:role:edit") @PostMapping("/changeStatus") @ResponseBody public AjaxResult changeStatus(SysRole role) { return toAjax(roleService.changeStatus(role)); }
Example #27
Source File: SysRoleServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 根据用户ID查询角色 * * @param userId 用户ID * @return 角色列表 */ @Override public List<SysRole> selectRolesByUserId(Long userId) { List<SysRole> userRoles = roleMapper.selectRolesByUserId(userId); List<SysRole> roles = selectRoleAll(); for (SysRole role : roles) { for (SysRole userRole : userRoles) { if (role.getRoleId().equals(userRole.getRoleId())) { role.setFlag(true); break; } } } return roles; }
Example #28
Source File: SysRoleServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 根据用户ID查询权限 * * @param userId 用户ID * @return 权限列表 */ @Override public Set<String> selectRoleKeys(Long userId) { List<SysRole> perms = roleMapper.selectRolesByUserId(userId); Set<String> permsSet = new HashSet<>(); for (SysRole perm : perms) { if (StringUtils.isNotNull(perm)) { permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); } } return permsSet; }
Example #29
Source File: SysRoleController.java From ruoyiplus with MIT License | 5 votes |
/** * 新增保存角色 */ @RequiresPermissions("system:role:add") @Log(title = "角色管理", businessType = BusinessType.INSERT) @PostMapping("/add") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult addSave(SysRole role) { role.setCreateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(roleService.insertRole(role)); }
Example #30
Source File: SysRoleServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 批量删除角色信息 * * @param ids 需要删除的数据ID * @throws BusinessException 异常 */ @Override public int deleteRoleByIds(String ids) { Long[] roleIds = Convert.toLongArray(ids); for (Long roleId : roleIds) { SysRole role = selectRoleById(roleId); if (countUserRoleByRoleId(roleId) > 0) { throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName())); } } return roleMapper.deleteRoleByIds(roleIds); }