Przeglądaj źródła

修改根据部门id查找公路列表业务,新增部门为顶级部门,查询所有公路列表逻辑

tags/v1.0.0^2
wanjing 1 rok temu
rodzic
commit
0cdaaa0f04
2 zmienionych plików z 43 dodań i 6 usunięć
  1. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java
  2. +33
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/road/query/QueryRoadListByDeptIdService.java

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java Wyświetl plik

@@ -0,0 +1,10 @@
package com.tuoheng.admin.constant;

public interface SystemConstant {

/**
* 顶级部门pid,默认为0
*/
Integer ROOT_DEPT_PID = 0;

}

+ 33
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/road/query/QueryRoadListByDeptIdService.java Wyświetl plik

@@ -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;
}

Ładowanie…
Anuluj
Zapisz