From c813046594b82230cd2cb61622d68a4981096e08 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 02 八月 2021 19:28:41 +0800 Subject: [PATCH] update 日常校验 统一重构到 StringUtils 便于维护扩展 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 70a33ee..a9ecb36 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -1,6 +1,5 @@ package com.ruoyi.system.service.impl; -import cn.hutool.core.lang.Validator; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; @@ -9,6 +8,7 @@ import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleMenu; @@ -91,7 +91,7 @@ List<SysRole> perms = baseMapper.selectRolePermissionByUserId(userId); Set<String> permsSet = new HashSet<>(); for (SysRole perm : perms) { - if (Validator.isNotNull(perm)) { + if (StringUtils.isNotNull(perm)) { permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); } } @@ -138,10 +138,10 @@ */ @Override public String checkRoleNameUnique(SysRole role) { - Long roleId = Validator.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = getOne(new LambdaQueryWrapper<SysRole>() .eq(SysRole::getRoleName, role.getRoleName()).last("limit 1")); - if (Validator.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -155,10 +155,10 @@ */ @Override public String checkRoleKeyUnique(SysRole role) { - Long roleId = Validator.isNull(role.getRoleId()) ? -1L : role.getRoleId(); + Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = getOne(new LambdaQueryWrapper<SysRole>() .eq(SysRole::getRoleKey, role.getRoleKey()).last("limit 1")); - if (Validator.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -171,7 +171,7 @@ */ @Override public void checkRoleAllowed(SysRole role) { - if (Validator.isNotNull(role.getRoleId()) && role.isAdmin()) { + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { throw new CustomException("涓嶅厑璁告搷浣滆秴绾х鐞嗗憳瑙掕壊"); } } -- Gitblit v1.9.3