<?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.house365.ws.dao.mapper.SignUpTrackMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.SignUpTrackEntity">
        <result property="id" column="id"/>
        <result property="customerId" column="customer_id"/>
        <result property="phone" column="phone"/>
        <result property="city" column="city"/>
        <result property="signUpTime" column="sign_up_time"/>
    </resultMap>


    <insert id="save" parameterType="com.house365.beans.entity.SignUpTrackEntity">
        INSERT INTO sign_up_track (
            customer_id,
            phone,
            city,
            sign_up_time
        )
        VALUES (
            #{customerId},
            #{phone},
            #{city},
            #{signUpTime}
        )
    </insert>

    <select id="queryByConditions" resultMap="infoMap" parameterType="map">
        SELECT *
        FROM sign_up_track
        where 1 = 1
        <if test="customerId != null and customerId != ''">
            AND customer_id = #{customerId}
        </if>
        <if test="phone != null and phone != ''">
            AND phone = #{phone}
        </if>
    </select>


    <delete id="deleteMessage" parameterType="map">
        delete FROM sign_up_track
        where #{time} > sign_up_time
    </delete>

</mapper>