龚焕茏
2024-05-15 468109c399d40c1a1f3c30bd443e09951aaf4a64
src/main/resources/mapper/UserMapper.xml
@@ -508,4 +508,27 @@
        ]]>
    </select>
    <update id="updateUserDeptAdmin">
        update t_user set role = -1 where id in
        <foreach collection="adminIds" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </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>
</mapper>