<?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.GroupChatActivityRewardDetailLogMapper">
    <resultMap type="com.gic.haoban.manage.service.entity.chat.TabGroupChatActivityRewardDetailLog"
               id="TabHaobanGroupChatActivityRewardDetailLogMap">
        <result property="chatActivityRewardDetailId" column="chat_activity_reward_detail_id" jdbcType="INTEGER"/>
        <result property="chatActivityRewardId" column="chat_activity_reward_id" jdbcType="INTEGER"/>
        <result property="chatActivityId" column="chat_activity_id" jdbcType="INTEGER"/>
        <result property="activityRewardId" column="activity_reward_id" jdbcType="INTEGER"/>
        <result property="memberId" column="member_id" jdbcType="VARCHAR"/>
        <result property="rewardType" column="reward_type" jdbcType="INTEGER"/>
        <result property="rewardValue" column="reward_value" jdbcType="VARCHAR"/>
        <result property="rewardName" column="reward_name" jdbcType="VARCHAR"/>
        <result property="rewardRemark" column="reward_remark" jdbcType="VARCHAR"/>
        <result property="rewardBusinessId" column="reward_business_id" jdbcType="VARCHAR"/>
        <result property="successFlag" column="success_flag" 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_detail_id
        , chat_activity_reward_id, chat_activity_id,
        activity_reward_id, member_id, reward_type, reward_value,
            reward_name, reward_remark, reward_business_id,
        success_flag, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
    </sql>

    <!--查询单个-->
    <select id="queryById" resultMap="TabHaobanGroupChatActivityRewardDetailLogMap">
        select chat_activity_reward_detail_id, chat_activity_reward_id, chat_activity_id, activity_reward_id, member_id, reward_type, reward_value, reward_name, reward_remark, reward_business_id, success_flag, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_reward_detail_log
        where chat_activity_reward_detail_id = #{chatActivityRewardDetailId}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanGroupChatActivityRewardDetailLogMap">
        select
        chat_activity_reward_detail_id, chat_activity_reward_id, chat_activity_id, activity_reward_id, member_id, reward_type, reward_value, reward_name, reward_remark, reward_business_id, success_flag, enterprise_id, wx_enterprise_id, create_time, update_time, delete_flag
        from tab_haoban_group_chat_activity_reward_detail_log
        <where>
            <if test="chatActivityRewardDetailId != null">
                and chat_activity_reward_detail_id = #{chatActivityRewardDetailId}
            </if>
            <if test="chatActivityRewardId != null">
                and chat_activity_reward_id = #{chatActivityRewardId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="activityRewardId != null">
                and activity_reward_id = #{activityRewardId}
            </if>
            <if test="memberId != null and memberId != ''">
                and member_id = #{memberId}
            </if>
            <if test="rewardType != null">
                and reward_type = #{rewardType}
            </if>
            <if test="rewardValue != null and rewardValue != ''">
                and reward_value = #{rewardValue}
            </if>
            <if test="rewardName != null and rewardName != ''">
                and reward_name = #{rewardName}
            </if>
            <if test="rewardRemark != null and rewardRemark != ''">
                and reward_remark = #{rewardRemark}
            </if>
            <if test="rewardBusinessId != null and rewardBusinessId != ''">
                and reward_business_id = #{rewardBusinessId}
            </if>
            <if test="successFlag != null">
                and success_flag = #{successFlag}
            </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_detail_log
        <where>
            <if test="chatActivityRewardDetailId != null">
                and chat_activity_reward_detail_id = #{chatActivityRewardDetailId}
            </if>
            <if test="chatActivityRewardId != null">
                and chat_activity_reward_id = #{chatActivityRewardId}
            </if>
            <if test="chatActivityId != null">
                and chat_activity_id = #{chatActivityId}
            </if>
            <if test="activityRewardId != null">
                and activity_reward_id = #{activityRewardId}
            </if>
            <if test="memberId != null and memberId != ''">
                and member_id = #{memberId}
            </if>
            <if test="rewardType != null">
                and reward_type = #{rewardType}
            </if>
            <if test="rewardValue != null and rewardValue != ''">
                and reward_value = #{rewardValue}
            </if>
            <if test="rewardName != null and rewardName != ''">
                and reward_name = #{rewardName}
            </if>
            <if test="rewardRemark != null and rewardRemark != ''">
                and reward_remark = #{rewardRemark}
            </if>
            <if test="rewardBusinessId != null and rewardBusinessId != ''">
                and reward_business_id = #{rewardBusinessId}
            </if>
            <if test="successFlag != null">
                and success_flag = #{successFlag}
            </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="chatActivityRewardDetailId" useGeneratedKeys="true">
        insert into tab_haoban_group_chat_activity_reward_detail_log(
            chat_activity_reward_detail_id,
            chat_activity_reward_id,
            chat_activity_id,
            activity_reward_id,
            member_id,
            reward_type,
            reward_value,
            reward_name,
            reward_remark,
            reward_business_id,
            success_flag,
            enterprise_id,
            wx_enterprise_id
        )
        values (
                   #{chatActivityRewardDetailId},
                   #{chatActivityRewardId},
                   #{chatActivityId},
                   #{activityRewardId},
                   #{memberId},
                   #{rewardType},
                   #{rewardValue},
                   #{rewardName},
                   #{rewardRemark},
                   #{rewardBusinessId},
                   #{successFlag},
                   #{enterpriseId},
                   #{wxEnterpriseId}
               )
    </insert>


    <!--通过主键修改数据-->
    <update id="update">
        update tab_haoban_group_chat_activity_reward_detail_log
        <set>
            <if test="chatActivityRewardId != null">
                chat_activity_reward_id = #{chatActivityRewardId},
            </if>
            <if test="chatActivityId != null">
                chat_activity_id = #{chatActivityId},
            </if>
            <if test="activityRewardId != null">
                activity_reward_id = #{activityRewardId},
            </if>
            <if test="memberId != null and memberId != ''">
                member_id = #{memberId},
            </if>
            <if test="rewardType != null">
                reward_type = #{rewardType},
            </if>
            <if test="rewardValue != null and rewardValue != ''">
                reward_value = #{rewardValue},
            </if>
            <if test="rewardName != null and rewardName != ''">
                reward_name = #{rewardName},
            </if>
            <if test="rewardRemark != null and rewardRemark != ''">
                reward_remark = #{rewardRemark},
            </if>
            <if test="rewardBusinessId != null and rewardBusinessId != ''">
                reward_business_id = #{rewardBusinessId},
            </if>
            <if test="successFlag != null">
                success_flag = #{successFlag},
            </if>
        </set>
        where chat_activity_reward_detail_id = #{chatActivityRewardDetailId}
    </update>


    <select id="queryList" resultMap="TabHaobanGroupChatActivityRewardDetailLogMap">
        select
        <include refid="Base_Column_List"></include>
        from tab_haoban_group_chat_activity_reward_detail_log
        where delete_flag = 0
        <if test="rewardLogIdList != null">
           and chat_activity_reward_id in
            <foreach collection="rewardLogIdList" item="rewardLogId" separator="," open="(" close=")">
                #{rewardLogId}
            </foreach>
        </if>
    </select>
</mapper>

