<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.system.mapper.UserDeptMapper">

    <select id="queryUserDeptIds" resultType="org.springblade.system.pojo.vo.UserDeptIdsVO">
        select
        group_concat(distinct bd.id) deptIds,
        group_concat(distinct bd.dept_code) deptCodes,
        bud.user_id
        from
        blade_user_dept bud
        left join blade_dept bd on bd.dept_code = bud.dept_code
        where
        bd.id is not null
        and bud.is_deleted = 0
        and bud.user_id in <foreach collection="userIds" item="item" separator="," open="(" close=")">#{item}</foreach>
        group by bud.user_id
    </select>

</mapper>
