Java Code Examples for com.ruoyi.common.utils.StringUtils#isNull()
The following examples show how to use
com.ruoyi.common.utils.StringUtils#isNull() .
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: GenTableServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 设置主键列信息 * * @param genTable 业务表信息 * @param columns 业务字段列表 */ public void setPkColumn(GenTable table, List<GenTableColumn> columns) { for (GenTableColumn column : columns) { if (column.isPk()) { table.setPkColumn(column); break; } } if (StringUtils.isNull(table.getPkColumn())) { table.setPkColumn(columns.get(0)); } }
Example 2
Source File: GenTableServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 设置主键列信息 * * @param table 业务表信息 * @param columns 业务字段列表 */ public void setPkColumn(GenTable table, List<GenTableColumn> columns) { for (GenTableColumn column : columns) { if (column.isPk()) { table.setPkColumn(column); break; } } if (StringUtils.isNull(table.getPkColumn())) { table.setPkColumn(columns.get(0)); } }
Example 3
Source File: TestController.java From RuoYi-Vue with MIT License | 6 votes |
@ApiOperation("更新用户") @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity") @PutMapping("/update") public AjaxResult update(UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { return AjaxResult.error("用户ID不能为空"); } if (users.isEmpty() || !users.containsKey(user.getUserId())) { return AjaxResult.error("用户不存在"); } users.remove(user.getUserId()); return AjaxResult.success(users.put(user.getUserId(), user)); }
Example 4
Source File: PermissionService.java From RuoYi-Vue with MIT License | 6 votes |
/** * 判断用户是否拥有某个角色 * * @param role 角色字符串 * @return 用户是否具备某角色 */ public boolean hasRole(String role) { if (StringUtils.isEmpty(role)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) { return false; } for (SysRole sysRole : loginUser.getUser().getRoles()) { String roleKey = sysRole.getRoleKey(); if (SUPER_ADMIN.contains(roleKey) || roleKey.contains(StringUtils.trim(role))) { return true; } } return false; }
Example 5
Source File: SysUserOnlineServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 设置在线用户信息 * * @param user 用户信息 * @return 在线用户 */ @Override public SysUserOnline loginUserToUserOnline(LoginUser user) { if (StringUtils.isNull(user) && StringUtils.isNull(user.getUser())) { return null; } SysUserOnline sysUserOnline = new SysUserOnline(); sysUserOnline.setTokenId(user.getToken()); sysUserOnline.setUserName(user.getUsername()); sysUserOnline.setIpaddr(user.getIpaddr()); sysUserOnline.setLoginLocation(user.getLoginLocation()); sysUserOnline.setBrowser(user.getBrowser()); sysUserOnline.setOs(user.getOs()); sysUserOnline.setLoginTime(user.getLoginTime()); if (StringUtils.isNotNull(user.getUser().getDept())) { sysUserOnline.setDeptName(user.getUser().getDept().getDeptName()); } return sysUserOnline; }
Example 6
Source File: PermissionService.java From RuoYi-Vue with MIT License | 6 votes |
/** * 验证用户是否具有以下任意一个权限 * * @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表 * @return 用户是否具有以下任意一个权限 */ public boolean hasAnyPermi(String permissions) { if (StringUtils.isEmpty(permissions)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) { return false; } Set<String> authorities = loginUser.getPermissions(); for (String permission : permissions.split(PERMISSION_DELIMETER)) { if (permission != null && hasPermissions(authorities, permission)) { return true; } } return false; }
Example 7
Source File: SysUserServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验email是否唯一 * * @param user 用户信息 * @return */ @Override public String checkEmailUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkEmailUnique(user.getEmail()); if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.USER_EMAIL_NOT_UNIQUE; } return UserConstants.USER_EMAIL_UNIQUE; }
Example 8
Source File: SysPostServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验岗位名称是否唯一 * * @param post 岗位信息 * @return 结果 */ @Override public String checkPostNameUnique(SysPost post) { Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); SysPost info = postMapper.checkPostNameUnique(post.getPostName()); if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { return UserConstants.POST_NAME_NOT_UNIQUE; } return UserConstants.POST_NAME_UNIQUE; }
Example 9
Source File: SysRoleServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验角色名称是否唯一 * * @param role 角色信息 * @return 结果 */ @Override public String checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.ROLE_NAME_NOT_UNIQUE; } return UserConstants.ROLE_NAME_UNIQUE; }
Example 10
Source File: SysUserServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验用户名称是否唯一 * * @param user 用户信息 * @return */ @Override public String checkPhoneUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example 11
Source File: SysPostServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 校验岗位编码是否唯一 * * @param post 岗位信息 * @return 结果 */ @Override public String checkPostCodeUnique(SysPost post) { Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId(); SysPost info = postMapper.checkPostCodeUnique(post.getPostCode()); if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue()) { return UserConstants.POST_CODE_NOT_UNIQUE; } return UserConstants.POST_CODE_UNIQUE; }
Example 12
Source File: SysUserServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验用户名称是否唯一 * * @param user 用户信息 * @return */ @Override public String checkPhoneUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.USER_PHONE_NOT_UNIQUE; } return UserConstants.USER_PHONE_UNIQUE; }
Example 13
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 校验菜单名称是否唯一 * * @param menu 菜单信息 * @return 结果 */ @Override public String checkMenuNameUnique(SysMenu menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.MENU_NAME_NOT_UNIQUE; } return UserConstants.MENU_NAME_UNIQUE; }
Example 14
Source File: PermissionService.java From RuoYi-Vue with MIT License | 5 votes |
/** * 验证用户是否具备某权限 * * @param permission 权限字符串 * @return 用户是否具备某权限 */ public boolean hasPermi(String permission) { if (StringUtils.isEmpty(permission)) { return false; } LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) { return false; } return hasPermissions(loginUser.getPermissions(), permission); }
Example 15
Source File: SysRoleServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验角色名称是否唯一 * * @param role 角色信息 * @return 结果 */ @Override public String checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example 16
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 校验部门名称是否唯一 * * @param dept 部门信息 * @return 结果 */ @Override public String checkDeptNameUnique(SysDept dept) { Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { return UserConstants.DEPT_NAME_NOT_UNIQUE; } return UserConstants.DEPT_NAME_UNIQUE; }
Example 17
Source File: SysDictTypeServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验字典类型称是否唯一 * * @param dict 字典类型 * @return 结果 */ @Override public String checkDictTypeUnique(SysDictType dict) { Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId(); SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType()); if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example 18
Source File: SysUserServiceImpl.java From ruoyiplus with MIT License | 4 votes |
/** * 导入用户数据 * * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 * @param operName 操作用户 * @return 结果 */ @Override public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) { if (StringUtils.isNull(userList) || userList.size() == 0) { throw new BusinessException("导入用户数据不能为空!"); } int successNum = 0; int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); String password = configService.selectConfigByKey("sys.user.initPassword"); for (SysUser user : userList) { try { // 验证是否存在这个用户 SysUser u = userMapper.selectUserByLoginName(user.getLoginName()); if (StringUtils.isNull(u)) { user.setPassword(Md5Utils.hash(user.getLoginName() + password)); user.setCreateBy(operName); this.insertUser(user); successNum++; successMsg.append("<br/>" + successNum + "、账号 " + user.getLoginName() + " 导入成功"); } else if (isUpdateSupport) { user.setUpdateBy(operName); this.updateUser(user); successNum++; successMsg.append("<br/>" + successNum + "、账号 " + user.getLoginName() + " 更新成功"); } else { failureNum++; failureMsg.append("<br/>" + failureNum + "、账号 " + user.getLoginName() + " 已存在"); } } catch (Exception e) { failureNum++; String msg = "<br/>" + failureNum + "、账号 " + user.getLoginName() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); log.error(msg, e); } } if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new BusinessException(failureMsg.toString()); } else { successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } return successMsg.toString(); }
Example 19
Source File: DemoOperateController.java From supplierShop with MIT License | 4 votes |
/** * 导入用户数据 * * @param userList 用户数据列表 * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据 * @return 结果 */ public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport) { if (StringUtils.isNull(userList) || userList.size() == 0) { throw new BusinessException("导入用户数据不能为空!"); } int successNum = 0; int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); for (UserOperateModel user : userList) { try { // 验证是否存在这个用户 boolean userFlag = false; for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet()) { if (entry.getValue().getUserName().equals(user.getUserName())) { userFlag = true; break; } } if (!userFlag) { Integer userId = users.size() + 1; user.setUserId(userId); users.put(userId, user); successNum++; successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功"); } else if (isUpdateSupport) { users.put(user.getUserId(), user); successNum++; successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功"); } else { failureNum++; failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在"); } } catch (Exception e) { failureNum++; String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); } } if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new BusinessException(failureMsg.toString()); } else { successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } return successMsg.toString(); }
Example 20
Source File: SysShiroService.java From ruoyiplus with MIT License | 2 votes |
/** * 获取会话信息 * * @param sessionId * @return */ public Session getSession(Serializable sessionId) { SysUserOnline userOnline = onlineService.selectOnlineById(String.valueOf(sessionId)); return StringUtils.isNull(userOnline) ? null : createSession(userOnline); }