Java Code Examples for com.ruoyi.common.utils.StringUtils#isNotNull()
The following examples show how to use
com.ruoyi.common.utils.StringUtils#isNotNull() .
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: SysDictTypeServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 根据字典类型查询字典数据 * * @param dictType 字典类型 * @return 字典数据集合信息 */ @Override public List<SysDictData> selectDictDataByType(String dictType) { List<SysDictData> dictDatas = DictUtils.getDictCache(dictType); if (StringUtils.isNotNull(dictDatas)) { return dictDatas; } dictDatas = dictDataMapper.selectDictDataByType(dictType); if (StringUtils.isNotNull(dictDatas)) { DictUtils.setDictCache(dictType, dictDatas); return dictDatas; } return null; }
Example 2
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 3
Source File: SysShiroService.java From supplierShop with MIT License | 6 votes |
public Session createSession(SysUserOnline userOnline) { OnlineSession onlineSession = new OnlineSession(); if (StringUtils.isNotNull(userOnline)) { onlineSession.setId(userOnline.getSessionId()); onlineSession.setHost(userOnline.getIpaddr()); onlineSession.setBrowser(userOnline.getBrowser()); onlineSession.setOs(userOnline.getOs()); onlineSession.setDeptName(userOnline.getDeptName()); onlineSession.setLoginName(userOnline.getLoginName()); onlineSession.setStartTimestamp(userOnline.getStartTimestamp()); onlineSession.setLastAccessTime(userOnline.getLastAccessTime()); onlineSession.setTimeout(userOnline.getExpireTime()); } return onlineSession; }
Example 4
Source File: SysUserServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 新增用户角色信息 * * @param user 用户对象 */ public void insertUserRole(SysUser user) { Long[] roles = user.getRoleIds(); if (StringUtils.isNotNull(roles)) { // 新增用户与角色管理 List<SysUserRole> list = new ArrayList<SysUserRole>(); for (Long roleId : roles) { SysUserRole ur = new SysUserRole(); ur.setUserId(user.getUserId()); ur.setRoleId(roleId); list.add(ur); } if (list.size() > 0) { userRoleMapper.batchUserRole(list); } } }
Example 5
Source File: SysUserController.java From RuoYi-Vue with MIT License | 6 votes |
/** * 根据用户编号获取详细信息 */ @PreAuthorize("@ss.hasPermi('system:user:query')") @GetMapping(value = { "/", "/{userId}" }) public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) { AjaxResult ajax = AjaxResult.success(); List<SysRole> roles = roleService.selectRoleAll(); ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); ajax.put("posts", postService.selectPostAll()); if (StringUtils.isNotNull(userId)) { ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId)); ajax.put("postIds", postService.selectPostListByUserId(userId)); ajax.put("roleIds", roleService.selectRoleListByUserId(userId)); } return ajax; }
Example 6
Source File: SysUserServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 新增用户角色信息 * * @param user 用户对象 */ public void insertUserRole(SysUser user) { Long[] roles = user.getRoleIds(); if (StringUtils.isNotNull(roles)) { // 新增用户与角色管理 List<SysUserRole> list = new ArrayList<SysUserRole>(); for (Long roleId : roles) { SysUserRole ur = new SysUserRole(); ur.setUserId(user.getUserId()); ur.setRoleId(roleId); list.add(ur); } if (list.size() > 0) { userRoleMapper.batchUserRole(list); } } }
Example 7
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 对象转部门树 * * @param deptList 部门列表 * @param roleDeptList 角色已存在菜单列表 * @return 树结构列表 */ public List<Ztree> initZtree(List<SysDept> deptList, List<String> roleDeptList) { List<Ztree> ztrees = new ArrayList<Ztree>(); boolean isCheck = StringUtils.isNotNull(roleDeptList); for (SysDept dept : deptList) { if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { Ztree ztree = new Ztree(); ztree.setId(dept.getDeptId()); ztree.setpId(dept.getParentId()); ztree.setName(dept.getDeptName()); ztree.setTitle(dept.getDeptName()); if (isCheck) { ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); } ztrees.add(ztree); } } return ztrees; }
Example 8
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 9
Source File: SysDeptServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 得到子节点列表 */ private List<SysDept> getChildList(List<SysDept> list, SysDept t) { List<SysDept> tlist = new ArrayList<SysDept>(); Iterator<SysDept> it = list.iterator(); while (it.hasNext()) { SysDept n = (SysDept) it.next(); if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { tlist.add(n); } } return tlist; }
Example 10
Source File: SysUserOnlineController.java From RuoYi-Vue with MIT License | 5 votes |
@PreAuthorize("@ss.hasPermi('monitor:online:list')") @GetMapping("/list") public TableDataInfo list(String ipaddr, String userName) { Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*"); List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); for (String key : keys) { LoginUser user = redisCache.getCacheObject(key); if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) { if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) { userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); } } else if (StringUtils.isNotEmpty(ipaddr)) { if (StringUtils.equals(ipaddr, user.getIpaddr())) { userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); } } else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) { if (StringUtils.equals(userName, user.getUsername())) { userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); } } else { userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); } } Collections.reverse(userOnlineList); userOnlineList.removeAll(Collections.singleton(null)); return getDataTable(userOnlineList); }
Example 11
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 12
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 13
Source File: AjaxResult.java From RuoYi-Vue with MIT License | 5 votes |
/** * 初始化一个新创建的 AjaxResult 对象 * * @param code 状态码 * @param msg 返回内容 * @param data 数据对象 */ public AjaxResult(int code, String msg, Object data) { super.put(CODE_TAG, code); super.put(MSG_TAG, msg); if (StringUtils.isNotNull(data)) { super.put(DATA_TAG, data); } }
Example 14
Source File: SysUserServiceImpl.java From supplierShop 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 15
Source File: SysUserServiceImpl.java From supplierShop 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 16
Source File: GenTableServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 设置代码生成其他选项值 * * @param genTable 设置后的生成对象 */ public void setTableFromOptions(GenTable genTable) { JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); if (StringUtils.isNotNull(paramsObj)) { String treeCode = paramsObj.getString(GenConstants.TREE_CODE); String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); String treeName = paramsObj.getString(GenConstants.TREE_NAME); genTable.setTreeCode(treeCode); genTable.setTreeParentCode(treeParentCode); genTable.setTreeName(treeName); } }
Example 17
Source File: BaseController.java From supplierShop with MIT License | 5 votes |
/** * 设置请求分页数据 */ protected void startPage() { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) { String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); PageHelper.startPage(pageNum, pageSize, orderBy); } }
Example 18
Source File: BaseController.java From ruoyiplus with MIT License | 5 votes |
/** * 设置请求分页数据 */ protected void startPage() { PageDomain pageDomain = TableSupport.buildPageRequest(); Integer pageNum = pageDomain.getPageNum(); Integer pageSize = pageDomain.getPageSize(); if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) { String orderBy = pageDomain.getOrderBy(); PageHelper.startPage(pageNum, pageSize, orderBy); } }
Example 19
Source File: SysMenuServiceImpl.java From RuoYi-Vue 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.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example 20
Source File: SysDeptServiceImpl.java From ruoyiplus 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; }