<?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.CloudCountMapper">

    <resultMap id="infoMap" type="com.house365.beans.entity.CloudCountEntity">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="count" column="count"/>
        <result property="waitCount" column="wait_count"/>
        <result property="sendCount" column="send_count"/>
        <result property="paiRate" column="pai_rate"/>
        <result property="backCount" column="back_count"/>
        <result property="backRate" column="back_rate"/>
        <result property="abCount" column="ab_count"/>
        <result property="abRate" column="ab_rate"/>
        <result property="seeCount" column="see_count"/>
        <result property="seeRate" column="see_rate"/>
        <result property="daoCount" column="dao_count"/>
        <result property="daoRate" column="dao_rate"/>
        <result property="buyCount" column="buy_count"/>
        <result property="signCount" column="sign_count"/>
        <result property="successCount" column="success_count"/>
        <result property="successRate" column="success_rate"/>
        <result property="createTime" column="create_time"/>
        <result property="createId" column="create_id"/>
        <result property="city" column="city"/>
        <result property="type" column="type"/>
    </resultMap>

    <sql id="sqlId">
        id,name,count,wait_count,send_count,pai_rate,back_count,back_rate,ab_count,ab_rate,see_count,see_rate,
        dao_count,dao_rate,buy_count,sign_count,success_count,success_rate,create_id,create_time,city,type
    </sql>

    <insert id="save" parameterType="com.house365.beans.entity.CloudCountEntity">
        INSERT INTO cloud_count (
        name,
        count,
        wait_count,
        send_count,
        pai_rate,
        back_count,
        back_rate,
        ab_count,
        ab_rate,
        see_count,
        see_rate,
        dao_count,
        dao_rate,
        buy_count,
        sign_count,
        success_count,
        success_rate,
        create_id,
        create_time,
        city,
        type
        )
        VALUES (
        #{name},
        #{count},
        #{waitCount},
        #{sendCount},
        #{paiRate},
        #{backCount},
        #{backRate},
        #{abCount},
        #{abRate},
        #{seeCount},
        #{seeRate},
        #{daoCount},
        #{daoRate},
        #{buyCount},
        #{signCount},
        #{successCount},
        #{successRate},
        #{createId},
        #{createTime},
        #{city},
        #{type}
        )
    </insert>

    <select id="getById" resultMap="infoMap" parameterType="map">
        SELECT
        <include refid="sqlId"/>
        FROM
        cloud_count
        WHERE id = #{id}
    </select>

    <select id="queryByConditions" resultMap="infoMap" parameterType="map">
        SELECT
        <include refid="sqlId"/>
        FROM
        cloud_count
        where 1 = 1
        <if test="name != null and name != ''">
            AND name LIKE CONCAT('%',#{name},'%')
        </if>
        <if test="startTime != null and startTime != ''">
            AND create_time between #{startTime} AND #{endTime}
        </if>
        <if test="createId != null and createId > 0">
            AND create_id = #{createId}
        </if>
        <if test="city != null and city != ''">
            AND city = #{city}
        </if>
        <if test="type != null and type >= 0">
            AND type = #{type}
        </if>
    </select>

</mapper>