Pu Zhibing
2025-01-04 c8ea2d96f5b0522a09f3203ae98fe796084d2d15
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -228,13 +228,13 @@
    @Override
    public int insertDept(SysDept dept)
    {
        SysDept info = deptMapper.selectDeptById(dept.getParentId());
        // 如果父节点不为正常状态,则不允许新增子节点
        if (null != info && !UserConstants.DEPT_NORMAL.equals(info.getStatus()))
        {
            throw new ServiceException("部门停用,不允许新增");
        }
        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
//        SysDept info = deptMapper.selectDeptById(dept.getParentId());
//        // 如果父节点不为正常状态,则不允许新增子节点
//        if (null != info && !UserConstants.DEPT_NORMAL.equals(info.getStatus()))
//        {
//            throw new ServiceException("部门停用,不允许新增");
//        }
//        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
        //判断店铺数据
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserService.getById(userid);
@@ -253,14 +253,14 @@
    @Override
    public int updateDept(SysDept dept)
    {
        SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
        SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
            String oldAncestors = oldDept.getAncestors();
            dept.setAncestors(newAncestors);
            updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
        }
//        SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
//        SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
//        if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
//            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
//            String oldAncestors = oldDept.getAncestors();
//            dept.setAncestors(newAncestors);
//            updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
//        }
        //判断店铺数据
        Long userid = tokenService.getLoginUser().getUserid();
        SysUser sysUser = sysUserService.getById(userid);