if((select count(1) from sys_user u left join sys_user_dprb b on u.user_id = b.user_id where b.dept_id=d.dept_id and d.status=1 and u.status=1)=0 and (select count(1) from sys_dept s where s.parent_id=d.dept_id and s.status=1)=0,'false','true') hasChildren
from sys_dept d
<where>
d.status = '1' and d.history_id like '001' '%'
<iftest="deptId != null and deptId != '' and deptId != '0'.toString()">
<!--and d.ancestors LIKE CONCAT((SELECT t.ancestors FROM sys_dept t where t.dept_id = #{deptId}),'%') -->
select dept_id, (select dept_short from sys_dept where dept_id=d.parent_id) as company_name, d.dept_short, d.dept_name, parent_id, d.history_id from sys_dept d
<where>
d.status = '1' and d.history_id like '001' '%'
<!--<if test="auth.deptId != null and auth.deptId != '' and auth.deptId != '0'.toString()">-->
<!--and d.parent_id = #{auth.deptId}-->
<!--</if>-->
<iftest="auth.ancestors != null">
and d.ancestors like CONCAT('%', CONCAT(#{auth.ancestors}), '%')
</if>
<iftest="auth.deptname != null">
and d.dept_short like CONCAT('%', CONCAT(#{auth.deptname}), '%')
</if>
<iftest="auth.isshow=='yes'">
and d.dept_id in (SELECT dept_permission from sys_dept_permission where property = #{auth.deptId} and isshow=#{auth.isshow})
</if>
<iftest="auth.isshow=='no'">
and d.dept_id not in (SELECT dept_permission from sys_dept_permission where property = #{auth.deptId} and isshow=#{auth.isshow})
select * from sys_dept where from_unit=#{fromUnit} and parent_id = (select dept_id from sys_dept where parent_id='0' and from_unit='0' and del_flag='0') and del_flag='0' and used_for_statistics='1' order by order_num asc
select d.*,(select GROUP_CONCAT(distinct dept_id) from sys_dept where parent_id=d.dept_id) as child_dept_ids
from sys_dept d where d.from_unit=#{fromUnit} and d.parent_id = (select dept_id from sys_dept where parent_id='0' and from_unit='0' and del_flag='0') and d.del_flag='0' and d.used_for_statistics='1' order by d.order_num asc
select u.user_id, u.history_id, u.shortcut,(SELECT d.dept_name from sys_dept d JOIN sys_user_dprb sud on d.dept_id = sud.dept_id JOIN sys_user su on sud.user_id = su.user_id where su.user_id = #{userId} ORDER BY d.parent_id asc LIMIT 0,1) as dept_name,
select d.dept_id, (select dept_short from sys_dept where dept_id=d.parent_id) as company_name, d.dept_short, d.dept_name, u.user_name ,u.user_id, u.history_id from sys_dept d,sys_user u,sys_user_dprb s
<where>
d.dept_id=s.dept_id and u.user_id=s.user_id and d.status = '1' and d.history_id like '001' '%' and s.status='1' and u.status='1'
and d.ancestors like CONCAT('%', CONCAT(#{ancestors}), '%')
and u.user_name like CONCAT('%', CONCAT(#{username}), '%')