递归查询

select id,name from sys_dept where pids like '%1067246875800000065%' and del_flag = 0

select id,name from sys_dept where pid ='1067246875800000065' and del_flag = 0

 


/**
* getChildSubDeptIdList
* @return
*/
@GetMapping("getChildSubDeptIdList")
@ApiOperation("getChildSubDeptIdList")
public Result<List<Long>> getChildSubDeptIdList(){
List<Long> idList =new ArrayList<>();
List<Long> data = sysDeptService.getChildSubDeptIdList(1067246875800000065L,idList);
return new Result<List<Long>>().ok(data);
}



/**
*
* @param id 部门ID
* @return
*/
@Override
public List<Long> getChildSubDeptIdList(Long id,List<Long> idList) {
List<Long> deptIdList = baseDao.getChildSubDeptIdList(id);
for (int i=0;i<deptIdList.size();i++){
Long deptId= deptIdList.get(i);
idList.add(deptId);
getChildSubDeptIdList(deptId,idList);
}
deptIdList.add(id);
return idList;
}

/**
* 根据部门ID,获取所有子部门ID列表
* @param id 部门ID
*/
List<Long> getChildSubDeptIdList(Long id);


<select id="getChildSubDeptIdList" resultType="long">
select id from sys_dept where pid = #{id} and del_flag = 0
</select>
上一篇:Angular常用方法记录


下一篇:JDBC事务,银行转账,货物进出库等等。