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

This commit is contained in:
2022-11-28 10:14:37 +08:00
parent ae39bcf84c
commit a9f0b494b0
9 changed files with 80 additions and 2 deletions

View File

@@ -313,6 +313,20 @@ public class DeptController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptList, methodDescribe);
}
/**
* 根据部门id获取所有子部门的code
* @author cdf
* @date 2022/11/25
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getDepSonSelfCodetByDeptId")
@ApiOperation("根据部门id获取所有子部门以及自身的code")
public HttpResult<List<String>> getDepSonSelfCodetByDeptId(@RequestParam("deptId")String deptId) {
String methodDescribe = getMethodDescribe("getDepSonSelfIdtByDeptId");
List<String> deptList = deptService.getDepSonSelfCodetByDeptId(deptId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptList, methodDescribe);
}
/**
* 根据部门id获取子部门ids
* @author dhj

View File

@@ -103,6 +103,13 @@ public interface DeptMapper extends BaseMapper<Dept> {
*/
List<String> getDeptSonIds(@Param("deptId") String deptId);
/**
* 根据部门id获取所有子部门以及自己code集合
* @author cdf
* @date 2022/7/26
*/
List<String> getDeptSonSlfeIds(@Param("deptId") String deptId);
/**
* 根据部门id获取子部门id集合
* @author dhj

View File

@@ -166,6 +166,12 @@
select id from sys_dept where find_in_set(#{deptId},pids) and state = 1
</select>
<select id="getDeptSonSlfeIds" resultType="String">
select code from sys_dept where find_in_set(#{deptId},pids) and state = 1
</select>
<select id="getDeptSonId" resultType="String">
select id from sys_dept where sys_dept.Pid=#{deptId} and state = 1
</select>

View File

@@ -163,6 +163,13 @@ public interface IDeptService extends IService<Dept> {
*/
List<String> getDepSonIdtByDeptId(String id);
/**
* 根据部门id获取部门详情
* @author cdf
* @date 2022/7/13
*/
List<String> getDepSonSelfCodetByDeptId(String id);
/**
* 根据部门id获取子部门ids
* @author dhj

View File

@@ -1,6 +1,7 @@
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;
@@ -324,7 +325,20 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements ID
*/
@Override
public List<String> getDepSonIdtByDeptId(String id) {
return this.baseMapper.getDeptSonIds(id);
List<String> sonIds = this.baseMapper.getDeptSonIds(id);
if(CollectionUtil.isNotEmpty(sonIds)){
sonIds.add(id);
}
return sonIds;
}
@Override
public List<String> getDepSonSelfCodetByDeptId(String id) {
List<String> sonIds = this.baseMapper.getDeptSonSlfeIds(id);
if(CollectionUtil.isNotEmpty(sonIds)){
sonIds.add(id);
}
return sonIds;
}
@Override