| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | |
| | | import org.dromara.system.mapper.SysRoleMapper; |
| | | import org.dromara.system.mapper.SysUserMapper; |
| | | import org.dromara.system.service.ISysDeptService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | private LambdaQueryWrapper<SysDept> buildQueryWrapper(SysDeptBo bo) { |
| | | LambdaQueryWrapper<SysDept> lqw = Wrappers.lambdaQuery(); |
| | | lqw.eq(SysDept::getDelFlag, "0"); |
| | | lqw.eq(SysDept::getDelFlag, UserConstants.DEL_FLAG_NORMAL); |
| | | lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId()); |
| | | lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getDeptCategory()), SysDept::getDeptCategory, bo.getDeptCategory()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysDept::getDeptId); |
| | | lqw.orderByAsc(SysDept::getAncestors); |
| | | lqw.orderByAsc(SysDept::getParentId); |
| | | lqw.orderByAsc(SysDept::getOrderNum); |
| | | lqw.orderByAsc(SysDept::getDeptId); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId())); |
| | | dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null); |
| | | return dept; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysDeptVo> selectDeptByIds(List<Long> deptIds) { |
| | | return baseMapper.selectDeptList(new LambdaQueryWrapper<SysDept>() |
| | | .select(SysDept::getDeptId, SysDept::getDeptName, SysDept::getLeader) |
| | | .eq(SysDept::getStatus, UserConstants.DEPT_NORMAL) |
| | | .in(CollUtil.isNotEmpty(deptIds), SysDept::getDeptId, deptIds)); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (LoginHelper.isSuperAdmin()) { |
| | | return; |
| | | } |
| | | SysDeptVo dept = baseMapper.selectDeptById(deptId); |
| | | if (ObjectUtil.isNull(dept)) { |
| | | if (baseMapper.countDeptById(deptId) == 0) { |
| | | throw new ServiceException("没有权限访问部门数据!"); |
| | | } |
| | | } |