<?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="cn.com.ctop.kuaishou.modules.clean.mapper.ProjectMonitorWhiteListMapper">

    <select id="getProjectIds" resultType="com.alibaba.fastjson.JSONObject">
        SELECT
        project.id as 'projectId',
        project.project_name as 'projectName'
        FROM
        (
        SELECT
        t1.project_id
        FROM
        ctop_project_monitor_white_list t1
        INNER JOIN (
        SELECT DISTINCT
        project_id
        FROM
        ctop_project_member
        WHERE 1 = 1
        <if test="userIds != null and userIds.size() > 0">
            and user_id in
            <foreach item="id" index="index" collection="userIds"
                     open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>

        ) t2 ON t1.project_id = t2.project_id
        ) white INNER JOIN ctop_project project
        ON white.project_id = project.id

    </select>
</mapper>