新增查询挡墙部门直属下级部门(没有下级部门返回当前部门)接口
This commit is contained in:
@@ -18,7 +18,9 @@ import java.util.List;
|
||||
* @date 2022/1/11
|
||||
* 部门相关业务对外接口
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.USER, path = "/dept", fallbackFactory = DeptFeignClientFallbackFactory.class)
|
||||
@FeignClient(value = ServerInfo.USER,
|
||||
// url = "http://127.0.0.1:10201",
|
||||
path = "/dept", fallbackFactory = DeptFeignClientFallbackFactory.class)
|
||||
public interface DeptFeignClient {
|
||||
|
||||
/**
|
||||
@@ -103,4 +105,14 @@ public interface DeptFeignClient {
|
||||
*/
|
||||
@GetMapping("/getRootDept")
|
||||
HttpResult<Dept> getRootDept();
|
||||
|
||||
/**
|
||||
* @Description: 获取当前部门的的下级子部门list,如果没子部门就是返回当前部门
|
||||
* @Param: [deptId]
|
||||
* @return: com.njcn.common.pojo.response.HttpResult<java.util.List<com.njcn.user.pojo.po.Dept>>
|
||||
* @Author: clam
|
||||
* @Date: 2023/1/10
|
||||
*/
|
||||
@GetMapping("/getDepSonDetailIdByDeptId")
|
||||
HttpResult<List<DeptDTO>> getDepSonDetailByDeptId(@RequestParam("deptId")String deptId) ;
|
||||
}
|
||||
|
||||
@@ -111,6 +111,12 @@ public class DeptFeignClientFallbackFactory implements FallbackFactory<DeptFeign
|
||||
log.error("{}异常,降级处理,异常为:{}","查询根部门异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
@Override
|
||||
public HttpResult<List<DeptDTO>> getDepSonDetailByDeptId(String deptId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询前部门的的下级子部门list,(如果没子部门就是返回当前部门)",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -392,6 +392,21 @@ public class DeptController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @Description: "获取当前部门的的下级子部门list,如果没子部门就是返回当前部门
|
||||
* @Param: [deptId]
|
||||
* @return: com.njcn.common.pojo.response.HttpResult<java.util.List<com.njcn.user.pojo.dto.DeptDTO>>
|
||||
* @Author: clam
|
||||
* @Date: 2023/1/10
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getDepSonDetailIdByDeptId")
|
||||
@ApiOperation("获取当前部门的的下级子部门list,如果没子部门就是返回当前部门")
|
||||
public HttpResult<List<DeptDTO>> getDepSonDetailByDeptId(@RequestParam("deptId")String deptId) {
|
||||
String methodDescribe = getMethodDescribe("getDepSonDetailByDeptId");
|
||||
List<DeptDTO> deptList = deptService.getDepSonDetailByDeptId(deptId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptList, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.user.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.pojo.dto.AreaTreeDTO;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.param.DeptParam;
|
||||
@@ -11,7 +10,6 @@ import com.njcn.user.pojo.vo.DeptAllTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptVO;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -200,4 +198,12 @@ public interface IDeptService extends IService<Dept> {
|
||||
* @date 2023/1/6
|
||||
*/
|
||||
Dept getRootDept();
|
||||
/**
|
||||
* @Description: 获取当前部门的的下级子部门list,如果没子部门就是返回当前部门
|
||||
* @Param: [deptId]
|
||||
* @return: java.util.List<com.njcn.user.pojo.dto.DeptDTO>
|
||||
* @Author: clam
|
||||
* @Date: 2023/1/10
|
||||
*/
|
||||
List<DeptDTO> getDepSonDetailByDeptId(String deptId);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.njcn.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
@@ -27,13 +27,14 @@ import com.njcn.user.pojo.vo.DeptTreeVO;
|
||||
import com.njcn.user.pojo.vo.DeptVO;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import com.njcn.user.service.IDeptService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.web.utils.WebUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -371,4 +372,34 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
|
||||
lambdaQueryWrapper.eq(Dept::getState,DataStateEnum.ENABLE.getCode()).eq(Dept::getPid,0);
|
||||
return this.getOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deptId
|
||||
* @Description: "获取当前部门的的下级子部门list,如果没子部门就是返回当前部门
|
||||
* @Param: [deptId]
|
||||
* @return: java.util.List<com.njcn.user.pojo.po.Dept>
|
||||
* @Author: clam
|
||||
* @Date: 2023/1/10
|
||||
*/
|
||||
@Override
|
||||
public List<DeptDTO> getDepSonDetailByDeptId(String deptId) {
|
||||
List<Dept> result = new ArrayList<> ();
|
||||
|
||||
LambdaQueryWrapper<Dept> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq (Dept::getPid, deptId).
|
||||
eq (Dept::getState,DataStateEnum.ENABLE.getCode());
|
||||
result = this.baseMapper.selectList (lambdaQueryWrapper);
|
||||
if(CollectionUtils.isEmpty (result)){
|
||||
LambdaQueryWrapper<Dept> deptLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
deptLambdaQueryWrapper.eq (Dept::getId, deptId).
|
||||
eq (Dept::getState,DataStateEnum.ENABLE.getCode());
|
||||
result = this.baseMapper.selectList (deptLambdaQueryWrapper);
|
||||
}
|
||||
List<DeptDTO> collect = result.stream ( ).map (temp -> {
|
||||
DeptDTO deptDTO = new DeptDTO ( );
|
||||
BeanUtils.copyProperties (temp, deptDTO);
|
||||
return deptDTO;
|
||||
}).collect (Collectors.toList ( ));
|
||||
return collect;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user