添加获取公司节点信息接口
This commit is contained in:
@@ -2,6 +2,7 @@ package com.zt.plat.module.system.api.dept;
|
|||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.util.collection.CollectionUtils;
|
import com.zt.plat.framework.common.util.collection.CollectionUtils;
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
import com.zt.plat.module.system.api.dept.dto.*;
|
import com.zt.plat.module.system.api.dept.dto.*;
|
||||||
import com.zt.plat.module.system.enums.ApiConstants;
|
import com.zt.plat.module.system.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -15,6 +16,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.NAME) // TODO ZT:fallbackFactory =
|
@FeignClient(name = ApiConstants.NAME) // TODO ZT:fallbackFactory =
|
||||||
@Tag(name = "RPC 服务 - 部门")
|
@Tag(name = "RPC 服务 - 部门")
|
||||||
public interface DeptApi {
|
public interface DeptApi {
|
||||||
@@ -86,6 +89,11 @@ public interface DeptApi {
|
|||||||
@Parameter(name = "userId", description = "用户编号", example = "1", required = true)
|
@Parameter(name = "userId", description = "用户编号", example = "1", required = true)
|
||||||
CommonResult<Set<CompanyDeptInfoRespDTO>> getCompanyDeptInfoListByUserId(@RequestParam("userId") Long userId);
|
CommonResult<Set<CompanyDeptInfoRespDTO>> getCompanyDeptInfoListByUserId(@RequestParam("userId") Long userId);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX+"/up-find-company-node")
|
||||||
|
@Operation(summary = "获取公司节点信息", description = "通过部门编号,向上追溯部门信息,直到上级部门是公司,返回追溯到的部门信息列表")
|
||||||
|
@Parameter(name = "deptId", description = "部门编号", required = true, example = "1024")
|
||||||
|
CommonResult<List<DeptRespDTO>> upFindCompanyNode(@RequestParam("deptId") Long deptId);
|
||||||
|
|
||||||
// ========== 数据同步专用接口 ==========
|
// ========== 数据同步专用接口 ==========
|
||||||
|
|
||||||
@PostMapping(PREFIX + "/sync")
|
@PostMapping(PREFIX + "/sync")
|
||||||
|
|||||||
@@ -107,6 +107,12 @@ public class DeptApiImpl implements DeptApi {
|
|||||||
return success(BeanUtils.toBean(companyDeptInfos, CompanyDeptInfoRespDTO.class));
|
return success(BeanUtils.toBean(companyDeptInfos, CompanyDeptInfoRespDTO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<List<DeptRespDTO>> upFindCompanyNode(Long deptId) {
|
||||||
|
List<DeptDO> depts = deptService.upFindCompanyNode(deptId);
|
||||||
|
return success(BeanUtils.toBean(depts, DeptRespDTO.class));
|
||||||
|
}
|
||||||
|
|
||||||
// ========== 数据同步专用接口 ==========
|
// ========== 数据同步专用接口 ==========
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -165,4 +165,11 @@ public class DeptController {
|
|||||||
return success(BeanUtils.toBean(companyDeptInfos, CompanyDeptInfoRespDTO.class));
|
return success(BeanUtils.toBean(companyDeptInfos, CompanyDeptInfoRespDTO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/up-find-company-node")
|
||||||
|
@Operation(summary = "获取公司节点信息", description = "通过部门编号,向上追溯部门信息,直到上级部门是公司,返回追溯到的部门信息列表")
|
||||||
|
@Parameter(name = "deptId", description = "部门编号", required = true, example = "1024")
|
||||||
|
public CommonResult<List<DeptRespVO>> upFindCompanyNode(@RequestParam("deptId") Long deptId) {
|
||||||
|
List<DeptDO> list = deptService.upFindCompanyNode(deptId);
|
||||||
|
return success(BeanUtils.toBean(list, DeptRespVO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||||||
import com.zt.plat.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
import com.zt.plat.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
||||||
import com.zt.plat.module.system.dal.dataobject.dept.DeptDO;
|
import com.zt.plat.module.system.dal.dataobject.dept.DeptDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -167,4 +169,9 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Select("""
|
||||||
|
SELECT sd.* FROM SYSTEM_DEPT sd START WITH sd.id = #{deptId}
|
||||||
|
CONNECT BY PRIOR sd.parent_id = sd.id AND PRIOR sd.is_company <> 1 ;
|
||||||
|
""")
|
||||||
|
List<DeptDO> upFindCompanyNode(@Param("deptId") Long deptId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,4 +185,11 @@ public interface DeptService {
|
|||||||
// ========== 数据同步专用接口 ==========
|
// ========== 数据同步专用接口 ==========
|
||||||
|
|
||||||
void syncDept(DeptSaveReqVO syncReqVO);
|
void syncDept(DeptSaveReqVO syncReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向上查找公司节点信息
|
||||||
|
* @param deptId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DeptDO> upFindCompanyNode(Long deptId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -960,4 +960,9 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
// 注意:不发布变更事件,避免循环同步
|
// 注意:不发布变更事件,避免循环同步
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeptDO> upFindCompanyNode(Long deptId) {
|
||||||
|
return deptMapper.upFindCompanyNode(deptId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user