<?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.GroupChatActivityShareBindMapper">
    <resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityShareBind" id="TabHaobanGroupChatActivityShareBindMap">
        <result property="chatActivityBindId" column="chat_activity_bind_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="inviteeUnionId" column="invitee_union_id" jdbcType="VARCHAR"/>
        <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="TabHaobanGroupChatActivityShareBindMap">
        select chat_activity_bind_id, chat_activity_id, inviter_member_id, invitee_member_id, invitee_union_id, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_share_bind
        where chat_activity_bind_id = #{chatActivityBindId}
    </select>

    <select id="query24Record" resultMap="TabHaobanGroupChatActivityShareBindMap">
        select chat_activity_bind_id, chat_activity_id, inviter_member_id, invitee_member_id, invitee_union_id, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_share_bind
        where delete_flag = 0
        and invitee_union_id in
        <foreach collection="inviteeUnionIds" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
        and create_time > now() - interval 1 day
        order by create_time desc
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanGroupChatActivityShareBindMap">
        select
        chat_activity_bind_id, chat_activity_id, inviter_member_id, invitee_member_id, invitee_union_id, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_share_bind
        <where>
            <if test="chatActivityBindId != null">
                and chat_activity_bind_id = #{chatActivityBindId}
            </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="inviteeUnionId != null and inviteeUnionId != ''">
                and invitee_union_id = #{inviteeUnionId}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(1)
        from tab_haoban_group_chat_activity_share_bind
        <where>
            <if test="chatActivityBindId != null">
                and chat_activity_bind_id = #{chatActivityBindId}
            </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="inviteeUnionId != null and inviteeUnionId != ''">
                and invitee_union_id = #{inviteeUnionId}
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                and enterprise_id = #{enterpriseId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <!--新增所有列-->
    <insert id="insert" keyProperty="chatActivityBindId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity_share_bind(chat_activity_bind_id, chat_activity_id, inviter_member_id, invitee_member_id, invitee_union_id, enterprise_id,wx_enterprise_id)
        values (#{chatActivityBindId}, #{chatActivityId}, #{inviterMemberId}, #{inviteeMemberId}, #{inviteeUnionId}, #{enterpriseId}, #{wxEnterpriseId})
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update tab_haoban_group_chat_activity_share_bind
        <set>
            <if test="chatActivityId != null">
                chat_activity_id = #{chatActivityId},
            </if>
            <if test="inviterMemberId != null and inviterMemberId != ''">
                inviter_member_id = #{inviterMemberId},
            </if>
            <if test="inviteeMemberId != null and inviteeMemberId != ''">
                invitee_member_id = #{inviteeMemberId},
            </if>
            <if test="inviteeUnionId != null and inviteeUnionId != ''">
                invitee_union_id = #{inviteeUnionId},
            </if>
            <if test="enterpriseId != null and enterpriseId != ''">
                enterprise_id = #{enterpriseId},
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                wx_enterprise_id = #{wxEnterpriseId},
            </if>
        </set>
        where chat_activity_bind_id = #{chatActivityBindId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete
        from tab_haoban_group_chat_activity_share_bind
        where chat_activity_bind_id = #{chatActivityBindId}
    </delete>
</mapper>

