sql语句
select id,name from (select t1.id,t1.name,if(find_in_set(pid, @pids) > 0,@pids := concat(@pids, ',', id),0) as ischild
from(select id,pid,name from sys_dept t order by pid,id ) t1,
(select @pids := #{deptId}) t2 ) t3 where ischild != 0
#{deptId} : 你传入的部门id
pid : 你数据库表中部门与上级部门关联
id : 部门id