<?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.iamberry.wechat.service.mapper.AttenStatisticsMapper">
    <resultMap  id="BaseResultMap" type="AttenStatistics" >
        <result    column="atten_statistics_id"    property="attenStatisticsId" />
        <result    column="channel_id"    property="channelId" />
        <result    column="channel_type"    property="channelType" />
        <result    column="atten_statistics_open_id"    property="attenStatisticsOpenId" />
        <result    column="atten_statistics_status"    property="attenStatisticsStatus" />
        <result    column="atten_statistics_create_time"    property="attenStatisticsCreateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.atten_statistics_id,
        t.channel_id,
        t.channel_type,
        t.atten_statistics_open_id,
        t.atten_statistics_status,
        t.atten_statistics_create_time
    </sql>
    <select id="getAttenStatisticsList" resultMap="BaseResultMap" parameterType="AttenStatistics" >
        select
        <include refid="Base_List" />
        from tb_iamberry_channel_atten_statistics t
        <where>
            <if test="attenStatisticsId != null ">
                AND t.atten_statistics_id = #{attenStatisticsId}
            </if >
            <if test="channelId != null ">
                AND t.channel_id = #{channelId}
            </if >
            <if test="channelType != null ">
                AND t.channel_type = #{channelType}
            </if >
            <if test="attenStatisticsOpenId != null and attenStatisticsOpenId != ''">
                AND t.atten_statistics_open_id  like  CONCAT ('%',#{attenStatisticsOpenId},'%')
            </if >
            <if test="attenStatisticsStatus != null ">
                AND t.atten_statistics_status = #{attenStatisticsStatus}
            </if >
        </where>
    </select>
    <select id="getAttenStatisticsById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_channel_atten_statistics t
        where t.atten_statistics_id= #{attenStatisticsId}
    </select>
    <insert id="save" parameterType="AttenStatistics" >
        insert into
        tb_iamberry_channel_atten_statistics
        (
        channel_id,
        channel_type,
        atten_statistics_open_id,
        atten_statistics_status
        )
        values
        (
        #{channelId},
        #{channelType},
        #{attenStatisticsOpenId},
        #{attenStatisticsStatus}
        )
    </insert>
    <delete id="delete" parameterType="Integer" >
        delete FROM
        tb_iamberry_channel_atten_statistics
        where atten_statistics_id=#{attenStatisticsId}
    </delete>
</mapper>