<?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.pcloud.book.pcloudkeyword.dao.impl.PcloudTdDaoImpl" >
  <resultMap id="BaseResultMap" type="PcloudTd" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="td_guide" jdbcType="VARCHAR" property="tdGuide" />
    <result column="td_keyword" jdbcType="VARCHAR" property="tdKeyword" />
    <result column="reply_type" jdbcType="INTEGER" property="replyType" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="pic_url" jdbcType="VARCHAR" property="picUrl" />
    <result column="resource_id" jdbcType="INTEGER" property="resourceId" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, td_guide, td_keyword, reply_type, content, pic_url, resource_id, create_time
  </sql>

    <insert id="batchInsert"  parameterType="PcloudTd" useGeneratedKeys="true" keyProperty="id">
        insert into pcloud_td (
            td_guide,
            td_keyword,
            reply_type,
            content,
            pic_url,
            resource_id,
            create_time
        ) values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.tdGuide,jdbcType=VARCHAR},
            #{item.tdKeyword,jdbcType=VARCHAR},
            #{item.replyType,jdbcType=INTEGER},
            #{item.content,jdbcType=VARCHAR},
            #{item.picUrl,jdbcType=VARCHAR},
            #{item.resourceId,jdbcType=INTEGER},
            NOW()
            )
        </foreach>
    </insert>

    <delete id="deleteAll" >
        delete from pcloud_td
    </delete>

    <select id="listAll" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from pcloud_td
    </select>

    <select id="getTdKeyword" resultType="string">
        select td_keyword
        from pcloud_td
        limit 1
    </select>

</mapper>