select c.code, c.name FROM tbase_staff c LEFT join tm_inventory a on c.depart_no =a.code left join (select aa.dn_no,aa.code depart_code,cc.uuid,cc.`name`,cc.code,cc.state from tm_inventory aa left join tm_priv_inventory bb on aa.uuid=bb.inventory_id left join tm_user cc on cc.uuid=bb.user_id where cc.account=${"'"+loginuser+"'"}) b on a.dn_no = b.dn_no where 1=1 ${if(hierarchy<1, " and 1=1 "," and b.depart_code is not null ")} and a.state=1 and c.state = 1 and b.code is not null order by convert(c.name using gbk) 稍微改了一下sql 生产环境打印不出来树的sql |