From 8ea56d3b22432d7af3d14f3539e2cbf7c3dbb036 Mon Sep 17 00:00:00 2001 From: phanes <5411232+phanes@user.noreply.gitee.com> Date: 星期日, 07 十一月 2021 11:58:35 +0800 Subject: [PATCH] update 减少使用特定数据库函数 --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 0a2f8e6..995bd2d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -111,8 +111,7 @@ @Override public boolean hasChildByDeptId(Long deptId) { long result = count(new LambdaQueryWrapper<SysDept>() - .eq(SysDept::getParentId, deptId) - .last("limit 1")); + .eq(SysDept::getParentId, deptId)); return result > 0; } @@ -138,11 +137,11 @@ @Override public String checkDeptNameUnique(SysDept dept) { Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); - SysDept info = getOne(new LambdaQueryWrapper<SysDept>() + long count = count(new LambdaQueryWrapper<SysDept>() .eq(SysDept::getDeptName, dept.getDeptName()) .eq(SysDept::getParentId, dept.getParentId()) - .last("limit 1")); - if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { + .ne(SysDept::getDeptId, deptId)); + if (count > 0) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; -- Gitblit v1.9.3