疯狂的狮子li
2021-12-03 e763381186c3a1f74ed416ea79767ac73b984745
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -11,7 +11,7 @@
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.LoginUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.TreeBuildUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
@@ -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;
@@ -155,7 +154,7 @@
     */
    @Override
    public void checkDeptDataScope(Long deptId) {
        if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
        if (!SysUser.isAdmin(LoginUtils.getUserId())) {
            SysDept dept = new SysDept();
            dept.setDeptId(deptId);
            List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);