Commit f163e3e5673d59d10045d2a21c8ab220801560d5
1 parent
1701fd6a
fix(user): 修复部门层级查找逻辑
- 当找不到parentId=100的部门时,返回当前部门id作为默认值 - 修改顶级部门查找逻辑,返回顶级部门ID而不是null - 避免因返回null导致的空指针异常问题
Showing
3 changed files
with
20 additions
and
4 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/InspectionPlanController.java
| ... | ... | @@ -130,7 +130,11 @@ public class InspectionPlanController { |
| 130 | 130 | if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){ |
| 131 | 131 | pageReqVO.setCompanyId( null); |
| 132 | 132 | }else{ |
| 133 | - pageReqVO.setCompanyId(SecurityFrameworkUtils.getCompanyId()); | |
| 133 | + Long companyId = SecurityFrameworkUtils.getCompanyId(); | |
| 134 | + if(null == companyId || companyId == 0L || companyId == 100L){ | |
| 135 | + companyId = null; | |
| 136 | + } | |
| 137 | + pageReqVO.setCompanyId(companyId); | |
| 134 | 138 | } |
| 135 | 139 | } |
| 136 | 140 | PageResult<InspectionPlanRespVO> pageResult = inspectionPlanService.getInspectionPlanPage(pageReqVO); | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/MaintainPlanController.java
| ... | ... | @@ -129,7 +129,11 @@ public class MaintainPlanController { |
| 129 | 129 | if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){ |
| 130 | 130 | pageReqVO.setCompanyId( null); |
| 131 | 131 | }else{ |
| 132 | - pageReqVO.setCompanyId(SecurityFrameworkUtils.getCompanyId()); | |
| 132 | + Long companyId = SecurityFrameworkUtils.getCompanyId(); | |
| 133 | + if(null == companyId || companyId == 0L || companyId == 100L){ | |
| 134 | + companyId = null; | |
| 135 | + } | |
| 136 | + pageReqVO.setCompanyId(companyId); | |
| 133 | 137 | } |
| 134 | 138 | } |
| 135 | 139 | PageResult<MaintainPlanRespVO> pageResult = maintainPlanService.getMaintainPlanPage(pageReqVO); | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/road/RoadController.java
| ... | ... | @@ -3,6 +3,8 @@ package com.zteits.urbanops.module.garden.controller.admin.road; |
| 3 | 3 | import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; |
| 4 | 4 | import com.zteits.urbanops.module.system.api.permission.PermissionApi; |
| 5 | 5 | import jakarta.annotation.security.PermitAll; |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 6 | 8 | import org.springframework.web.bind.annotation.*; |
| 7 | 9 | import jakarta.annotation.Resource; |
| 8 | 10 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -37,6 +39,7 @@ import com.zteits.urbanops.module.garden.service.road.RoadService; |
| 37 | 39 | @RequestMapping("/garden/road") |
| 38 | 40 | @Validated |
| 39 | 41 | public class RoadController { |
| 42 | + private static final Logger log = LoggerFactory.getLogger(RoadController.class); | |
| 40 | 43 | |
| 41 | 44 | @Resource |
| 42 | 45 | private RoadService roadService; |
| ... | ... | @@ -94,7 +97,11 @@ public class RoadController { |
| 94 | 97 | if(permissionApi.hasAnyRoles(loginUserId, "super_admin")){ |
| 95 | 98 | pageReqVO.setCompanyId( null); |
| 96 | 99 | }else{ |
| 97 | - pageReqVO.setCompanyId(SecurityFrameworkUtils.getCompanyId()); | |
| 100 | + Long companyId = SecurityFrameworkUtils.getCompanyId(); | |
| 101 | + if(null == companyId || companyId == 0L || companyId == 100L){ | |
| 102 | + companyId = null; | |
| 103 | + } | |
| 104 | + pageReqVO.setCompanyId(companyId); | |
| 98 | 105 | } |
| 99 | 106 | } |
| 100 | 107 | PageResult<RoadRespVO> pageResult = roadService.getRoadPage(pageReqVO); |
| ... | ... | @@ -127,6 +134,7 @@ public class RoadController { |
| 127 | 134 | @GetMapping("/queryAllRoadList") |
| 128 | 135 | @PermitAll |
| 129 | 136 | public Map<String, Object> queryAllRoadList(@RequestParam(required = false) String roadName, @RequestParam(required = false) String deptCode, @RequestParam(required = false) String companyCode) { |
| 137 | + log.info("物联网查询道路:companyCode:{},roadName:{},deptCode:{}",companyCode,roadName,deptCode); | |
| 130 | 138 | RoadListReqVO reqVO = new RoadListReqVO(); |
| 131 | 139 | reqVO.setRoadName(roadName); |
| 132 | 140 | // 处理deptCode为空的情况 |
| ... | ... | @@ -141,7 +149,7 @@ public class RoadController { |
| 141 | 149 | roadMap.put("roadName", manager.getRoadName()); |
| 142 | 150 | return roadMap; |
| 143 | 151 | }).collect(Collectors.toList()); |
| 144 | - | |
| 152 | + | |
| 145 | 153 | // 构建返回格式 |
| 146 | 154 | Map<String, Object> result = new HashMap<>(); |
| 147 | 155 | result.put("msg", "操作成功"); | ... | ... |