Java Code Examples for com.ruoyi.system.domain.SysUser#isAdmin()
The following examples show how to use
com.ruoyi.system.domain.SysUser#isAdmin() .
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: SysMenuServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 根据用户查询菜单 * * @param user 用户信息 * @return 菜单列表 */ @Override public List<SysMenu> selectMenusByUser(SysUser user) { List<SysMenu> menus = new LinkedList<SysMenu>(); // 管理员显示所有菜单信息 if (user.isAdmin()) { menus = menuMapper.selectMenuNormalAll(); } else { menus = menuMapper.selectMenusByUserId(user.getUserId()); } return getChildPerms(menus, 0); }
Example 2
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 查询菜单集合 * * @return 所有菜单信息 */ @Override public List<SysMenu> selectMenuList(SysMenu menu, Long userId) { List<SysMenu> menuList = null; if (SysUser.isAdmin(userId)) { menuList = menuMapper.selectMenuList(menu); } else { menu.getParams().put("userId", userId); menuList = menuMapper.selectMenuListByUserId(menu); } return menuList; }
Example 3
Source File: UserRealm.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 授权 */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) { SysUser user = ShiroUtils.getSysUser(); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); // 管理员拥有所有权限 if (user.isAdmin()) { info.addRole("admin"); info.addStringPermission("*:*:*"); } else { // 角色列表 Set<String> roles = roleService.selectRoleKeys(user.getUserId()); // 功能列表 Set<String> menus = menuService.selectPermsByUserId(user.getUserId()); // 角色加入AuthorizationInfo认证对象 info.setRoles(roles); // 权限加入AuthorizationInfo认证对象 info.setStringPermissions(menus); } return info; }
Example 4
Source File: SysUserController.java From supplierShop with MIT License | 6 votes |
/** * 修改保存用户 */ @RequiresPermissions("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysUser user) { if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在"); } else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); } user.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(userService.updateUser(user)); }
Example 5
Source File: DataScopeAspect.java From ruoyiplus with MIT License | 6 votes |
protected void handleDataScope(final JoinPoint joinPoint) { // 获得注解 DataScope controllerDataScope = getAnnotationLog(joinPoint); if (controllerDataScope == null) { return; } // 获取当前的用户 SysUser currentUser = ShiroUtils.getSysUser(); if (currentUser != null) { // 如果是超级管理员,则不过滤数据 if (!currentUser.isAdmin()) { dataScopeFilter(joinPoint, currentUser, controllerDataScope.tableAlias()); } } }
Example 6
Source File: SysUserController.java From RuoYi with Apache License 2.0 | 6 votes |
@ApiOperation("新增用户") @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "SysUser") @RequiresPermissions("system:user:add") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping("/add") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult addSave(SysUser user) { if (ObjectUtil.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))){ return error("保存用户'" + user.getLoginName() + "'失败,账号已存在"); } user.setSalt(ShiroUtils.randomSalt()); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setCreateBy(ShiroUtils.getLoginName()); return toAjax(userService.insertUser(user)); }
Example 7
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 根据用户查询菜单 * * @param user 用户信息 * @return 菜单列表 */ @Override public List<SysMenu> selectMenusByUser(SysUser user) { List<SysMenu> menus = new LinkedList<SysMenu>(); // 管理员显示所有菜单信息 if (user.isAdmin()) { menus = menuMapper.selectMenuNormalAll(); } else { menus = menuMapper.selectMenusByUserId(user.getUserId()); } return getChildPerms(menus, 0); }
Example 8
Source File: SysUserController.java From ruoyiplus with MIT License | 6 votes |
/** * 新增保存用户 */ @RequiresPermissions("system:user:add") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping("/add") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult addSave(SysUser user) { if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } user.setSalt(ShiroUtils.randomSalt()); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setCreateBy(ShiroUtils.getLoginName()); return toAjax(userService.insertUser(user)); }
Example 9
Source File: SysUserServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 批量删除用户信息 * * @param ids 需要删除的数据ID * @return 结果 */ @Override public int deleteUserByIds(String ids) throws BusinessException { Long[] userIds = Convert.toLongArray(ids); for (Long userId : userIds) { if (SysUser.isAdmin(userId)) { throw new BusinessException("不允许删除超级管理员用户"); } } return userMapper.deleteUserByIds(userIds); }
Example 10
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 查询菜单集合 * * @param userId 用户ID * @return 所有菜单信息 */ @Override public List<SysMenu> selectMenuAll(Long userId) { List<SysMenu> menuList; if (SysUser.isAdmin(userId)){ menuList = menuMapper.selectMenuAll(); }else{ menuList = menuMapper.selectMenuAllByUserId(userId); } return menuList; }
Example 11
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 查询菜单集合 * * @param userId 用户ID * @return 所有菜单信息 */ @Override public List<SysMenu> selectMenuList(SysMenu menu, Long userId) { List<SysMenu> menuList; if (SysUser.isAdmin(userId)){ menuList = menuMapper.selectMenuList(menu); }else{ menu.getParams().put("userId", userId); menuList = menuMapper.selectMenuListByUserId(menu); } return menuList; }
Example 12
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 根据用户查询菜单 * * @param user 用户信息 * @return 菜单列表 */ @Override public List<SysMenu> selectMenusByUser(SysUser user) { List<SysMenu> menus; // 管理员显示所有菜单信息 if (user.isAdmin()) { menus = menuMapper.selectMenuNormalAll(); } else { menus = menuMapper.selectMenusByUserId(user.getUserId()); } return getChildPerms(menus, 0); }
Example 13
Source File: DataScopeAspect.java From RuoYi with Apache License 2.0 | 5 votes |
private void handleDataScope(final JoinPoint joinPoint) { // 获得注解 DataScope controllerDataScope = getAnnotationLog(joinPoint); if (controllerDataScope == null) { return; } // 获取当前的用户 SysUser currentUser = ShiroUtils.getSysUser(); if (ObjectUtil.isNotNull(currentUser) && !currentUser.isAdmin()) { // 如果是超级管理员,则不过滤数据 dataScopeFilter(joinPoint, currentUser, controllerDataScope.tableAlias()); } }
Example 14
Source File: SysUserController.java From ruoyiplus with MIT License | 5 votes |
/** * 修改保存用户 */ @RequiresPermissions("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult editSave(SysUser user) { if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } user.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(userService.updateUser(user)); }
Example 15
Source File: SysUserServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 用户状态修改 * * @param user 用户信息 * @return 结果 */ @Override public int changeStatus(SysUser user) { if (SysUser.isAdmin(user.getUserId())) { throw new BusinessException("不允许修改超级管理员用户"); } return userMapper.updateUser(user); }
Example 16
Source File: UserRealm.java From ruoyiplus with MIT License | 5 votes |
/** * 授权 */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) { SysUser user = ShiroUtils.getSysUser(); // 角色列表 Set<String> roles = new HashSet<String>(); // 功能列表 Set<String> menus = new HashSet<String>(); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); // 管理员拥有所有权限 if (user.isAdmin()) { info.addRole("admin"); info.addStringPermission("*:*:*"); } else { roles = roleService.selectRoleKeys(user.getUserId()); menus = menuService.selectPermsByUserId(user.getUserId()); // 角色加入AuthorizationInfo认证对象 info.setRoles(roles); // 权限加入AuthorizationInfo认证对象 info.setStringPermissions(menus); } return info; }
Example 17
Source File: SysUserController.java From RuoYi with Apache License 2.0 | 5 votes |
@ApiOperation("修改用户") @ApiImplicitParam(name = "user", value = "修改用户信息", dataType = "SysUser") @RequiresPermissions("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult editSave(SysUser user) { if (ObjectUtil.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } user.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(userService.updateUser(user)); }
Example 18
Source File: SysUserServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 用户状态修改 * * @param user 用户信息 * @return 结果 */ @Override public int changeStatus(SysUser user) { if (SysUser.isAdmin(user.getUserId())) { throw new BusinessException("不允许修改超级管理员用户"); } return userMapper.updateUser(user); }
Example 19
Source File: SysUserServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 批量删除用户信息 * * @param ids 需要删除的数据ID * @return 结果 */ @Override public int deleteUserByIds(String ids) throws BusinessException { Long[] userIds = Convert.toLongArray(ids); for (Long userId : userIds) { if (SysUser.isAdmin(userId)) { throw new BusinessException("不允许删除超级管理员用户"); } } return userMapper.deleteUserByIds(userIds); }
Example 20
Source File: UserRealm.java From supplierShop with MIT License | 5 votes |
/** * 授权 */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) { SysUser user = ShiroUtils.getSysUser(); // 角色列表 Set<String> roles = new HashSet<String>(); // 功能列表 Set<String> menus = new HashSet<String>(); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); // 管理员拥有所有权限 if (user.isAdmin()) { info.addRole("admin"); info.addStringPermission("*:*:*"); } else { roles = roleService.selectRoleKeys(user.getUserId()); menus = menuService.selectPermsByUserId(user.getUserId()); // 角色加入AuthorizationInfo认证对象 info.setRoles(roles); // 权限加入AuthorizationInfo认证对象 info.setStringPermissions(menus); } return info; }