<?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.GroupChatActivityRewardLogMapper">
    <resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityRewardLog" id="TabHaobanGroupChatActivityRewardLogMap">
        <result property="chatActivityRewardLogId" column="chat_activity_reward_log_id" jdbcType="INTEGER"/>
        <result property="chatActivityId" column="chat_activity_id" jdbcType="INTEGER"/>
        <result property="memberId" column="member_id" jdbcType="VARCHAR"/>
        <result property="rewardInvite" column="reward_invite" jdbcType="INTEGER"/>
        <result property="inviteLevel" column="invite_level" 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>

    <sql id="Base_Column_List">
        chat_activity_reward_log_id
        , chat_activity_id,
            member_id, reward_invite, invite_level,
        enterprise_id, wx_enterprise_id,
            create_time, update_time, delete_flag
    </sql>

    <!--查询单个-->
    <select id="queryById" resultMap="TabHaobanGroupChatActivityRewardLogMap">
        select chat_activity_reward_log_id, chat_activity_id, member_id, reward_invite, invite_level, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag

        from tab_haoban_group_chat_activity_reward_log
        where chat_activity_reward_log_id = #{chatActivityRewardLogId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanGroupChatActivityRewardLogMap">
        select
        chat_activity_reward_log_id, chat_activity_id, member_id, reward_invite, invite_level, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag

        from tab_haoban_group_chat_activity_reward_log
        <where>
            <if test="chatActivityRewardLogId != null">
                and chat_activity_reward_log_id = #{chatActivityRewardLogId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="memberId != null and memberId != ''">
                and member_id = #{memberId}
            </if>
            <if test="rewardInvite != null">
                and reward_invite = #{rewardInvite}
            </if>
            <if test="inviteLevel != null">
                and invite_level = #{inviteLevel}
            </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_reward_log
        <where>
            <if test="chatActivityRewardLogId != null">
                and chat_activity_reward_log_id = #{chatActivityRewardLogId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="memberId != null and memberId != ''">
                and member_id = #{memberId}
            </if>
            <if test="rewardInvite != null">
                and reward_invite = #{rewardInvite}
            </if>
            <if test="inviteLevel != null">
                and invite_level = #{inviteLevel}
            </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="chatActivityRewardLogId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity_reward_log(chat_activity_reward_log_id,chat_activity_id, member_id, reward_invite, invite_level, enterprise_id, wx_enterprise_id)
        values (#{chatActivityRewardLogId},#{chatActivityId}, #{memberId}, #{rewardInvite}, #{inviteLevel}, #{enterpriseId}, #{wxEnterpriseId})
    </insert>


    <!--通过主键修改数据-->
    <update id="update">
        update tab_haoban_group_chat_activity_reward_log
        <set>
            <if test="chatActivityId != null">
                chat_activity_id = #{chatActivityId},
            </if>
            <if test="memberId != null and memberId != ''">
                member_id = #{memberId},
            </if>
            <if test="rewardInvite != null">
                reward_invite = #{rewardInvite},
            </if>
            <if test="inviteLevel != null">
                invite_level = #{inviteLevel},
            </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_reward_log_id = #{chatActivityRewardLogId}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        delete
        from tab_haoban_group_chat_activity_reward_log
        where chat_activity_reward_log_id = #{chatActivityRewardLogId}
    </delete>

    <select id="queryList" resultMap="TabHaobanGroupChatActivityRewardLogMap">
        select
        <include refid="Base_Column_List"></include>
        from tab_haoban_group_chat_activity_reward_log
        where delete_flag = 0
        <if test="enterpriseId != null and enterpriseId != ''">
            and enterprise_id = #{enterpriseId}
        </if>
        <if test="chatActivityId != null">
            and chat_activity_id = #{chatActivityId}
        </if>
        <if test="memberId != null and memberId != ''">
            and member_id = #{memberId}
        </if>
        <if test="rewardInvite != null">
            and reward_invite = #{rewardInvite}
        </if>
        <if test="beginTime != null">
            and create_time &gt; #{beginTime}
        </if>
        <if test="endTime != null">
            and create_time &lt; #{endTime}
        </if>
        order by create_time desc
    </select>
</mapper>

