<?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.gic.haoban.manage.service.dao.mapper.chat.GroupChatActivityInviteLogMapper">
    <resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityInviteLog" id="TabHaobanGroupChatActivityInviteLogMap">
        <result property="chatActivityInviteId" column="chat_activity_invite_id" jdbcType="INTEGER"/>
        <result property="chatActivityId" column="chat_activity_id" jdbcType="INTEGER"/>
        <result property="inviterMemberId" column="inviter_member_id" jdbcType="VARCHAR"/>
        <result property="inviteeMemberId" column="invitee_member_id" jdbcType="VARCHAR"/>
        <result property="inviteeUserId" column="invitee_user_id" jdbcType="VARCHAR"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
        <result property="groupChatId" column="group_chat_id" jdbcType="INTEGER"/>
        <result property="inviteType" column="invite_type" jdbcType="INTEGER"/>
        <result property="invalidInviteType" column="invalid_invite_type" jdbcType="INTEGER"/>
        <result property="addMemberType" column="add_member_type" jdbcType="INTEGER"/>
        <result property="batchNumber" column="batch_number" jdbcType="INTEGER"/>
        <result property="enterpriseId" column="enterprise_id" jdbcType="VARCHAR"/>
        <result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="deleteFlag" column="delete_flag" jdbcType="INTEGER"/>
    </resultMap>

    <!--查询单个-->
    <select id="queryById" resultMap="TabHaobanGroupChatActivityInviteLogMap">
        select chat_activity_invite_id, chat_activity_id, inviter_member_id, invitee_member_id, invitee_user_id,
               user_name, nick_name, group_chat_id, invite_type, invalid_invite_type, add_member_type, batch_number,
               enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_invite_log
        where chat_activity_invite_id = #{chatActivityInviteId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanGroupChatActivityInviteLogMap">
        select chat_activity_invite_id, chat_activity_id, inviter_member_id, invitee_member_id, invitee_user_id,
        user_name, nick_name, group_chat_id, invite_type, invalid_invite_type, add_member_type, batch_number,
        enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_invite_log
        <where>
            <if test="chatActivityInviteId != null">
                and chat_activity_invite_id = #{chatActivityInviteId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="inviterMemberId != null and inviterMemberId != ''">
                and inviter_member_id = #{inviterMemberId}
            </if>
            <if test="inviteeMemberId != null and inviteeMemberId != ''">
                and invitee_member_id = #{inviteeMemberId}
            </if>
            <if test="inviteeUserId != null and inviteeUserId != ''">
                and invitee_user_id = #{inviteeUserId}
            </if>
            <if test="userName != null and userName != ''">
                and user_name = #{userName}
            </if>
            <if test="nickName != null and nickName != ''">
                and nick_name = #{nickName}
            </if>
            <if test="groupChatId != null">
                and group_chat_id = #{groupChatId}
            </if>
            <if test="inviteType != null">
                and invite_type = #{inviteType}
            </if>
            <if test="invalidInviteType != null">
                and invalid_invite_type = #{invalidInviteType}
            </if>
            <if test="addMemberType != null">
                and add_member_type = #{addMemberType}
            </if>
            <if test="batchNumber != null">
                and batch_number = #{batchNumber}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from tab_haoban_group_chat_activity_invite_log
        <where>
            <if test="chatActivityInviteId != null">
                and chat_activity_invite_id = #{chatActivityInviteId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="inviterMemberId != null and inviterMemberId != ''">
                and inviter_member_id = #{inviterMemberId}
            </if>
            <if test="inviteeMemberId != null and inviteeMemberId != ''">
                and invitee_member_id = #{inviteeMemberId}
            </if>
            <if test="inviteeUserId != null and inviteeUserId != ''">
                and invitee_user_id = #{inviteeUserId}
            </if>
            <if test="userName != null and userName != ''">
                and user_name = #{userName}
            </if>
            <if test="nickName != null and nickName != ''">
                and nick_name = #{nickName}
            </if>
            <if test="groupChatId != null">
                and group_chat_id = #{groupChatId}
            </if>
            <if test="inviteType != null">
                and invite_type = #{inviteType}
            </if>
            <if test="invalidInviteType != null">
                and invalid_invite_type = #{invalidInviteType}
            </if>
            <if test="addMemberType != null">
                and add_member_type = #{addMemberType}
            </if>
            <if test="batchNumber != null">
                and batch_number = #{batchNumber}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="createTime != null">
                and create_time = #{createTime}
            </if>
            <if test="updateTime != null">
                and update_time = #{updateTime}
            </if>
            <if test="deleteFlag != null">
                and delete_flag = #{deleteFlag}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="chatActivityInviteId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity_invite_log(chat_activity_id, inviter_member_id, invitee_member_id, invitee_user_id,
                                                              user_name, nick_name, group_chat_id, invite_type, invalid_invite_type, add_member_type, batch_number,
                                                              enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag)
        values (#{chatActivityId}, #{inviterMemberId}, #{inviteeMemberId}, #{inviteeUserId}, #{userName}, #{nickName},
                #{groupChatId}, #{inviteType}, #{invalidInviteType}, #{addMemberType}, #{batchNumber}, #{enterpriseId},
                #{wxEnterpriseId}, #{createTime}, #{updateTime}, #{deleteFlag})
    </insert>

    <insert id="insertBatch" keyProperty="chatActivityInviteId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity_invite_log(chat_activity_id, inviter_member_id, invitee_member_id, invitee_user_id,
        user_name, nick_name, group_chat_id, invite_type, invalid_invite_type, add_member_type, batch_number,
        enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.chatActivityId}, #{item.inviterMemberId}, #{item.inviteeMemberId}, #{item.inviteeUserId}, #{item.userName},
            #{item.nickName}, #{item.groupChatId}, #{item.inviteType}, #{item.invalidInviteType}, #{item.addMemberType},
            #{item.batchNumber}, #{item.enterpriseId}, #{item.wxEnterpriseId}, #{item.createTime}, #{item.updateTime}, #{item.deleteFlag})
        </foreach>
    </insert>

    <!-- 修改所有列 -->
    <update id="update">
        update tab_haoban_group_chat_activity_invite_log
        set chat_activity_id = #{chatActivityId}, inviter_member_id = #{inviterMemberId}, invitee_member_id = #{inviteeMemberId},
            invitee_user_id = #{inviteeUserId}, user_name = #{userName}, nick_name = #{nickName}, group_chat_id = #{groupChatId},
            invite_type = #{inviteType}, invalid_invite_type = #{invalidInviteType}, add_member_type = #{addMemberType},
            batch_number = #{batchNumber}, enterprise_id = #{enterpriseId}, wx_enterprise_id = #{wxEnterpriseId},
            create_time = #{createTime}, update_time = #{updateTime}, delete_flag = #{deleteFlag}
        where chat_activity_invite_id = #{chatActivityInviteId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete from tab_haoban_group_chat_activity_invite_log where chat_activity_invite_id = #{chatActivityInviteId}
    </delete>
</mapper>
