<?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="cn.com.countrygarden.bi.main.dao.phoenix.PhoenixSalesBuildMapper">
    <resultMap id="BaseResultMap" type="cn.com.countrygarden.bi.main.model.phoenix.PhoenixSalesBuild">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="areaid" jdbcType="VARCHAR" property="areaid"/>
        <result column="areaname" jdbcType="VARCHAR" property="areaname"/>
        <result column="yname" jdbcType="VARCHAR" property="yname"/>
        <result column="bldid" jdbcType="VARCHAR" property="bldid"/>
        <result column="bldname" jdbcType="VARCHAR" property="bldname"/>
    </resultMap>

    <insert id="persistence" useGeneratedKeys="true">
        REPLACE INTO phoenix_sales_build
        (areaid, areaname, yname, bldid, bldname)
        VALUES
        <foreach collection="builds" index="index" item="item" separator=",">
            (#{areaId}, #{areaName}, #{item.yname}, #{item.bldid}, #{item.bldname})
        </foreach>
    </insert>

    <delete id="truncate">
    TRUNCATE phoenix_sales_build
    </delete>

    <select id="search" resultMap="BaseResultMap">
        SELECT id, areaid, areaname, yname, bldid, bldname FROM phoenix_sales_build WHERE areaid = #{areaId}
    </select>
</mapper>