新增获取部门子集接口

This commit is contained in:
njcn_dhj
2022-10-09 10:48:45 +08:00
parent 5ba00aca0a
commit 070e0cab6e
7 changed files with 51 additions and 2 deletions

View File

@@ -67,4 +67,10 @@ public interface DeptFeignClient {
@GetMapping("/getDepSonIdtByDeptId") @GetMapping("/getDepSonIdtByDeptId")
HttpResult<List<String>> getDepSonIdtByDeptId(@RequestParam("deptId") String deptId); HttpResult<List<String>> getDepSonIdtByDeptId(@RequestParam("deptId") String deptId);
/**
* 根据部门id获取子部门ids
*/
@GetMapping("/getDepSonIdByDeptId")
HttpResult<List<String>> getDepSonIdByDeptId(@RequestParam("deptId") String deptId);
} }

View File

@@ -76,6 +76,11 @@ public class DeptFeignClientFallbackFactory implements FallbackFactory<DeptFeign
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<String>> getDepSonIdByDeptId(String deptId) {
log.error("{}异常,降级处理,异常为:{}","查询所有子孙部门异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -299,7 +299,19 @@ public class DeptController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptList, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptList, methodDescribe);
} }
/**
* 根据部门id获取子部门ids
* @author dhj
* @date 2022/10/09
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getDepSonIdByDeptId")
@ApiOperation("根据部门id获取子部门ids")
public HttpResult<List<String>> getDepSonIdByDeptId(@RequestParam("deptId")String deptId) {
String methodDescribe = getMethodDescribe("getDepSonIdByDeptId");
List<String> deptList = deptService.getDepSonIdByDeptId(deptId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptList, methodDescribe);
}
} }

View File

@@ -102,4 +102,11 @@ public interface DeptMapper extends BaseMapper<Dept> {
* @date 2022/7/26 * @date 2022/7/26
*/ */
List<String> getDeptSonIds(@Param("deptId") String deptId); List<String> getDeptSonIds(@Param("deptId") String deptId);
/**
* 根据部门id获取子部门id集合
* @author dhj
* @date 2022/10/09
*/
List<String> getDeptSonId(@Param("deptId") String deptId);
} }

View File

@@ -164,5 +164,8 @@
select id from sys_dept where find_in_set(#{deptId},pids) and state = 1 select id from sys_dept where find_in_set(#{deptId},pids) and state = 1
</select> </select>
<select id="getDeptSonId" resultType="String">
select id from sys_dept where sys_dept.Pid=#{deptId} and state = 1
</select>
</mapper> </mapper>

View File

@@ -155,4 +155,11 @@ public interface IDeptService extends IService<Dept> {
* @date 2022/7/13 * @date 2022/7/13
*/ */
List<String> getDepSonIdtByDeptId(String id); List<String> getDepSonIdtByDeptId(String id);
/**
* 根据部门id获取子部门ids
* @author dhj
* @date 2022/7/13
*/
List<String> getDepSonIdByDeptId(String id);
} }

View File

@@ -89,7 +89,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
Dept dept = new Dept(); Dept dept = new Dept();
BeanUtil.copyProperties(deptParam, dept); BeanUtil.copyProperties(deptParam, dept);
//进行先解绑,再新增 //进行先解绑,再新增
Integer httpResult=deptLineFeignClient.removeBind(deptParam.getPid()).getData(); Integer httpResult = deptLineFeignClient.removeBind(deptParam.getPid()).getData();
System.out.println(httpResult); System.out.println(httpResult);
if (deptParam.getPid().equals("-1")) { if (deptParam.getPid().equals("-1")) {
//上层节点 //上层节点
@@ -318,4 +318,13 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
public List<String> getDepSonIdtByDeptId(String id) { public List<String> getDepSonIdtByDeptId(String id) {
return this.baseMapper.getDeptSonIds(id); return this.baseMapper.getDeptSonIds(id);
} }
@Override
public List<String> getDepSonIdByDeptId(String id) {
List<String> sonId = this.baseMapper.getDeptSonId(id);
if (sonId.isEmpty()) {
sonId.add(id);
}
return sonId;
}
} }