| | |
| | | |
| | | <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department" parameterType="java.lang.Integer"> |
| | | <if test="id != null"> |
| | | select a.id, a.name, a.parent_id from t_department a inner join t_user_department b on a.id = b.department_id where a.deleted = 0 and b.dept_admin = 1 and b.user_id = #{id} order by a.id |
| | | WITH RECURSIVE temp_table AS ( |
| | | select a.id, a.name, a.parent_id from t_department a inner join t_user_department b on a.id = b.department_id where a.deleted = 0 and b.dept_admin = 1 and b.user_id = #{id} |
| | | UNION ALL |
| | | SELECT |
| | | so.id, so.name, so.parent_id FROM t_department so INNER JOIN temp_table tb ON so.parent_id = tb.id |
| | | ) |
| | | SELECT |
| | | id, name, parent_id |
| | | FROM |
| | | temp_table |
| | | </if> |
| | | <if test="id == null"> |
| | | select a.id, a.name, a.parent_id from t_department a where a.deleted = 0 order by a.id |