| | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | SysDept info = getById(dept.getParentId()); |
| | | // 如果父节点不为正常状态,则不允许新增子节点 |
| | | if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { |
| | | throw new ServiceException("部门停用,不允许新增"); |
| | | throw new ServiceException("机构停用,不允许新增"); |
| | | } |
| | | List<SysDept> list = baseMapper.selectList(new QueryWrapper<SysDept>().lambda().eq(SysDept::getCode, dept.getCode())); |
| | | if (list.size() > 0) { |
| | | throw new ServiceException("机构编号重复", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
| | | return baseMapper.insert(dept); |
| | |
| | | */ |
| | | @Override |
| | | public int updateDept(SysDept dept) { |
| | | List<SysDept> list = baseMapper.selectList(new QueryWrapper<SysDept>().lambda() |
| | | .eq(SysDept::getCode, dept.getCode()) |
| | | .ne(SysDept::getDeptId, dept.getDeptId())); |
| | | if (list.size() > 0) { |
| | | throw new ServiceException("机构编号重复", HttpStatus.HTTP_PARTIAL); |
| | | } |
| | | SysDept newParentDept = getById(dept.getParentId()); |
| | | SysDept oldDept = getById(dept.getDeptId()); |
| | | if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { |