<?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="com.github.wxiaoqi.security.admin.mapper.AppUserPositionTempMapper">
    <select id="getUserIdByParentCompany" resultType="Integer">
        SELECT
        r.uid
        FROM
        app_user_position_temp pt
        LEFT JOIN app_user_detail d ON pt.user_id = d.userid
        LEFT JOIN (
        SELECT
        parent_id AS pid,
        user_id AS uid
        FROM
        app_user_relation
        WHERE
        is_del = 0
        ) r ON d.userid = r.pid
        WHERE
        pt.is_del = 0
        <if test="parentCompanyId != null and parentCompanyId.size() !=0">
            AND pt.company_id IN
            <foreach collection="parentCompanyId" index="index" item="pid" open="(" separator="," close=")">
                #{pid}
            </foreach>
        </if>

    </select>
</mapper>