| | |
| | | </update> |
| | | |
| | | <update id="cancelUserDeptAdmin"> |
| | | update t_user set role = 1 where id in( |
| | | select user_id from t_user_department where department_id = #{id} and user_id not in |
| | | <foreach collection="adminIds" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | and user_id not in |
| | | (select user_id from t_user_department where dept_admin = 1 and user_id in |
| | | (select user_id from t_user_department where department_id = #{id} and user_id not in |
| | | <foreach collection="adminIds" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | ))) |
| | | update t_user set role = 1 where id in |
| | | <foreach collection="userIds" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </update> |
| | | |
| | | <select id="getDeptAdminIds" resultType="java.lang.Integer" parameterType="java.lang.Integer"> |
| | |
| | | dept_admin = 1 and user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department" parameterType="java.lang.Integer"> |
| | | <if test="id != null"> |
| | | <select id="getDeptAdmins" resultType="com.mindskip.xzs.domain.Department"> |
| | | <if test="ids != null and ids.size() != 0"> |
| | | 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} |
| | | select a.id, a.name, a.parent_id from t_department a WHERE id IN <foreach collection="ids" item="id" open="(" separator="," close=")"> #{id} </foreach> |
| | | 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 |
| | |
| | | FROM |
| | | temp_table |
| | | </if> |
| | | <if test="id == null"> |
| | | <if test="ids == null or ids.size() == 0"> |
| | | select a.id, a.name, a.parent_id from t_department a where a.deleted = 0 order by a.id |
| | | </if> |
| | | </select> |