<?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.GroupChatActivityJoinMapper">
    <resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityJoin" id="TabHaobanGroupChatActivityJoinMap">
        <result property="chatActivityJoinId" column="chat_activity_join_id" jdbcType="INTEGER"/>
        <result property="chatActivityId" column="chat_activity_id" jdbcType="INTEGER"/>
        <result property="memberType" column="member_type" jdbcType="INTEGER"/>
        <result property="filterJson" column="filter_json" jdbcType="VARCHAR"/>
        <result property="index" column="index" jdbcType="INTEGER"/>
        <result property="chatHmId" column="chat_hm_id" 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="TabHaobanGroupChatActivityJoinMap">
        select *
        from tab_haoban_group_chat_activity_join
        where chat_activity_join_id = #{chatActivityJoinId}
    </select>

    <select id="queryByChatActivityIds" resultMap="TabHaobanGroupChatActivityJoinMap">
        select *
        from tab_haoban_group_chat_activity_join
        where delete_flag = 0 and chat_activity_id in
        <foreach collection="chatActivityIds" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
        order by `index` asc
    </select>


    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanGroupChatActivityJoinMap">
        select
        chat_activity_join_id,chat_activity_id,member_type,filter_json,`index`,chat_hm_id,enterprise_id,wx_enterprise_id,create_time,update_time,delete_flag
        from tab_haoban_group_chat_activity_join
        <where>
            <if test="chatActivityJoinId != null">
                and chat_activity_join_id = #{chatActivityJoinId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="memberType != null">
                and member_type = #{memberType}
            </if>
            <if test="filterJson != null and filterJson != ''">
                and filter_json = #{filterJson}
            </if>
            <if test="index != null">
                and `index` = #{index}
            </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_join
        <where>
            <if test="chatActivityJoinId != null">
                and chat_activity_join_id = #{chatActivityJoinId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="memberType != null">
                and member_type = #{memberType}
            </if>
            <if test="filterJson != null and filterJson != ''">
                and filter_json = #{filterJson}
            </if>
            <if test="index != null">
                and `index` = #{index}
            </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="chatActivityJoinId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity_join(chat_activity_join_id,chat_activity_id,member_type,filter_json,`index`,chat_hm_id,enterprise_id,wx_enterprise_id)
        values (#{chatActivityJoinId},#{chatActivityId},#{memberType},#{filterJson},#{index},#{chatHmId},#{enterpriseId},#{wxEnterpriseId})
    </insert>


    <!--通过主键修改数据-->
    <update id="update">
        update tab_haoban_group_chat_activity_join
        <set>
            <if test="chatActivityId != null">
                chat_activity_id = #{chatActivityId},
            </if>
            <if test="memberType != null">
                member_type = #{memberType},
            </if>
            <if test="filterJson != null and filterJson != ''">
                filter_json = #{filterJson},
            </if>
            <if test="index != null">
                `index` = #{index},
            </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_join_id = #{chatActivityJoinId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        update
        tab_haoban_group_chat_activity_join set delete_flag = 1
        where chat_activity_join_id = #{chatActivityJoinId}
    </delete>
</mapper>

