龚焕茏
2024-07-19 2d928646669fe6026c7d63f6b409d9b2790aa65e
src/main/resources/mapper/UserMapper.xml
@@ -523,18 +523,10 @@
    </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">
@@ -551,10 +543,10 @@
            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
@@ -564,7 +556,7 @@
        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>