src/modules/basicdata/service/iot.ts
@@ -114,4 +114,24 @@ return result; } /** * 递归获取部门及其所有子部门 ID */ async getDepartmentAndChildren(deptId: number): Promise<number[]> { const result: number[] = [deptId]; const findChildren = async (pid: number) => { const children = await this.baseSysDepartmentEntity .createQueryBuilder('d') .select('d.id') .where('d.parentId = :pid', { pid }) .getMany(); for (const c of children) { result.push(c.id); await findChildren(c.id); } }; await findChildren(deptId); return result; } }