|
|
@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.road.query; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.constant.SystemConstant; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.RoadDept; |
|
|
|
import com.tuoheng.admin.entity.RoadInformation; |
|
|
@@ -52,8 +53,18 @@ public class QueryRoadListByDeptIdService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取该部门下公路列表 |
|
|
|
List<RoadInformation> roadInformationList = this.getRoadInformationList(tenantId, deptId); |
|
|
|
// 在校验中,判断部门是否存在时,若部门存在,直接将部门信息返回,减少数据库查询次数 |
|
|
|
Dept dept = (Dept) result.getData(); |
|
|
|
|
|
|
|
// 获取公路列表 |
|
|
|
List<RoadInformation> roadInformationList; |
|
|
|
if (SystemConstant.ROOT_DEPT_PID.equals(dept.getPid())) { |
|
|
|
// 顶级部门获取所有的公路列表 |
|
|
|
roadInformationList = this.getAllRoadInformationList(tenantId); |
|
|
|
} else { |
|
|
|
// 非顶级部门获取该部门下公路列表 |
|
|
|
roadInformationList = this.getRoadInformationListByDeptId(tenantId, deptId); |
|
|
|
} |
|
|
|
if (CollectionUtil.isEmpty(roadInformationList)) { |
|
|
|
log.info("根据部门Id查询公路列表业务:公路信息为空"); |
|
|
|
return JsonResult.error(QueryRoadListByDeptIdCodeEnum.ROAD_LIST_IS_NULL.getCode(), QueryRoadListByDeptIdCodeEnum.ROAD_LIST_IS_NULL.getMsg()); |
|
|
@@ -85,16 +96,32 @@ public class QueryRoadListByDeptIdService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询该部门下公路信息列表 |
|
|
|
* 如果是顶级部门,则查询所有公路列表 |
|
|
|
* |
|
|
|
* @param tenantId |
|
|
|
* @param id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<RoadInformation> getRoadInformationList(String tenantId, String id) { |
|
|
|
private List<RoadInformation> getAllRoadInformationList(String tenantId) { |
|
|
|
List<RoadInformation> roadList = roadInformationMapper.selectList(new LambdaQueryWrapper<RoadInformation>() |
|
|
|
.eq(RoadInformation::getTenantId, tenantId) |
|
|
|
.eq(RoadInformation::getMark, 1)); |
|
|
|
if (CollectionUtil.isEmpty(roadList)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return roadList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 如果是非顶级部门,则查询该部门下公路信息列表 |
|
|
|
* |
|
|
|
* @param tenantId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<RoadInformation> getRoadInformationListByDeptId(String tenantId, String deptId) { |
|
|
|
List<RoadDept> roadDeptList = roadDeptMapper.selectList(new LambdaQueryWrapper<RoadDept>() |
|
|
|
.eq(RoadDept::getTenantId, tenantId) |
|
|
|
.eq(RoadDept::getDeptId, id)); |
|
|
|
.eq(RoadDept::getDeptId, deptId)); |
|
|
|
if (CollectionUtil.isEmpty(roadDeptList)) { |
|
|
|
return null; |
|
|
|
} |