添加通过部门编号查询部门接口

This commit is contained in:
2022-11-22 10:35:00 +08:00
parent a81a815636
commit dba5edcd35
5 changed files with 40 additions and 1 deletions

View File

@@ -60,6 +60,11 @@ public interface DeptFeignClient {
@GetMapping("/getDeptById")
HttpResult<Dept> getDeptById(@RequestParam("deptId") String deptId);
/**
* 根据部门code获取部门信息
*/
@GetMapping("/getDeptByCode")
HttpResult<Dept> getDeptByCode(@RequestParam("deptCode") String deptCode);
/**
* 根据部门id获取所有子部门ids

View File

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

View File

@@ -271,7 +271,7 @@ public class DeptController extends BaseController {
}
/**
* 根据部门获取部门信息
* 根据部门Id获取部门信息
* @author cdf
* @date 2022/7/12
*/
@@ -284,6 +284,20 @@ public class DeptController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
/**
* 根据部门code获取部门信息
* @author cdf
* @date 2022/7/12
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getDeptByCode")
@ApiOperation("根据部门Id获取部门信息")
public HttpResult<Dept> getDeptByCode(@RequestParam("deptCode")String deptCode) {
String methodDescribe = getMethodDescribe("getDeptByCode");
Dept result = deptService.getDeptByCode(deptCode);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
/**
* 根据部门id获取所有子部门ids

View File

@@ -148,6 +148,13 @@ public interface IDeptService extends IService<Dept> {
*/
Dept getDeptById(String id);
/**
* 根据部门code获取部门详情
* @author cdf
* @date 2022/7/13
*/
Dept getDeptByCode(String deptCode);
/**
* 根据部门id获取部门详情

View File

@@ -266,6 +266,13 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
return this.baseMapper.selectById(id);
}
@Override
public Dept getDeptByCode(String deptCode) {
LambdaQueryWrapper<Dept> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Dept::getCode,deptCode).eq(Dept::getState,DataStateEnum.ENABLE.getCode());
return this.baseMapper.selectOne(lambdaQueryWrapper);
}
/**
* 校验参数,检查是否存在相同编码的部门