refactor(system): 优化部门和项目查询的 SQL 正则表达式
- 将 getChildDept 方法中的正则表达式替换为更高效的模糊查询组合 - 优化 ProjectMapper 中的参与部门查询条件,提高查询效率 - 在 DeptServiceImpl 中添加数据权限注解,控制访问权限
This commit is contained in:
parent
687d35eb53
commit
66419fe9ab
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.project.vo.ProjectPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.project.ProjectDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -23,13 +24,16 @@ public interface ProjectMapper extends BaseMapperX<ProjectDO> {
|
||||
.eqIfPresent(ProjectDO::getType, reqVO.getType())
|
||||
.likeIfPresent(ProjectDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ProjectDO::getResponsibleDept, reqVO.getResponsibleDept())
|
||||
// .likeIfPresent(ProjectDO::getParticipationDept, reqVO.getParticipationDept())
|
||||
.eqIfPresent(ProjectDO::getDirectorUserId, reqVO.getDirectorUserId())
|
||||
.betweenIfPresent(ProjectDO::getStartDate, reqVO.getStartDate())
|
||||
.betweenIfPresent(ProjectDO::getEndDate, reqVO.getEndDate())
|
||||
.eqIfPresent(ProjectDO::getIsLongTerm, reqVO.getIsLongTerm())
|
||||
.eqIfPresent(ProjectDO::getStatus, reqVO.getStatus())
|
||||
.apply(Objects.nonNull(reqVO.getParticipationDept()),"participation_dept REGEXP CONCAT('(^|,)',{0},'(,|$)')", reqVO.getParticipationDept())
|
||||
.likeLeft(ProjectDO::getParticipationDept, "-" + reqVO.getParticipationDept())
|
||||
.or()
|
||||
.likeRight(ProjectDO::getParticipationDept, reqVO.getParticipationDept() + "-")
|
||||
.or()
|
||||
.like(ProjectDO::getParticipationDept, "-" + reqVO.getParticipationDept() + "-")
|
||||
.orderByDesc(ProjectDO::getId));
|
||||
}
|
||||
}
|
@ -268,11 +268,17 @@ public class DeptServiceImpl implements DeptService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false)
|
||||
@Cacheable(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST, key = "#id")
|
||||
public List<DeptDO> getChildDept(Long id) {
|
||||
|
||||
return deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
.eq(DeptDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.apply("flag REGEXP CONCAT('(^|-)',{0},'(-|$)')", id));
|
||||
.likeLeft(DeptDO::getFlag, "-" + id)
|
||||
.or()
|
||||
.likeRight(DeptDO::getFlag, id + "-")
|
||||
.or()
|
||||
.like(DeptDO::getFlag, "-" + id + "-"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user