<?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="jnpf.notice.mapper.FtbNoticeUserGroupMembersMapper">

    <resultMap id="BaseResultMap" type="jnpf.model.notice.domain.FtbNoticeUserGroupMembers">
            <id property="id" column="F_Id" jdbcType="VARCHAR"/>
            <result property="groupId" column="F_GroupId" jdbcType="VARCHAR"/>
            <result property="userId" column="F_UserId" jdbcType="VARCHAR"/>
            <result property="creatorUserId" column="F_CreatorUserId" jdbcType="VARCHAR"/>
            <result property="creatorTime" column="F_CreatorTime" jdbcType="TIMESTAMP"/>
            <result property="tenantId" column="F_TenantId" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        F_Id,F_GroupId,F_UserId,F_CreatorUserId,F_CreatorTime,F_TenantId
    </sql>
    <!--分页查询用户分组列表-->
    <select id="pagingQuery" resultType="jnpf.model.notice.dto.FtbNoticeUserGroupMembersDto">
        select
        member.F_Id as id,
        member.F_UserId as userId
        from ftb_notice_user_group_members as member
        where member.F_GroupId = #{groupId}
        <if test="powerUserIds != null and powerUserIds.size() > 0">
            and member.F_UserId  in
            <foreach collection="powerUserIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
    <!--查询所有的用户分组列表-->
    <select id="queryAllList" resultType="jnpf.model.notice.dto.FtbNoticeUserGroupMembersDto">
        select
            member.F_Id as id,
            member.F_UserId as userId
        from ftb_notice_user_group_members as member
        where member.F_GroupId = #{groupId}
        <if test="powerUserIds != null and powerUserIds.size() > 0">
            and member.F_UserId  in
            <foreach collection="powerUserIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
    <!--根据分组id查询所有的用户分组列表-->
    <select id="queryAllListForGroupIds" resultType="jnpf.model.notice.dto.FtbNoticeUserGroupMembersDto">

        select
        member.F_Id as id,
        member.F_UserId as userId
        from ftb_notice_user_group_members as member
        where
        <if test="groupIds != null and groupIds.size() > 0">
            member.F_GroupId IN
            <foreach collection="groupIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>

        <if test="powerUserIds != null and powerUserIds.size() > 0">
            and member.F_UserId in
            <foreach collection="powerUserIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
</mapper>
