<?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.PcloudRobotWelcomeDaoImpl" >
  <resultMap id="BaseResultMap" type="PcloudRobotWelcome" >
    <id column="id" property="id" jdbcType="INTEGER" />
      <result column="pcloud_robot_id" property="pcloudRobotId" jdbcType="BIGINT"/>
      <result column="pcloud_classify_id" property="pcloudClassifyId" jdbcType="BIGINT"/>
      <result column="reply_type" property="replyType" jdbcType="INTEGER"/>
      <result column="content" property="content" jdbcType="VARCHAR"/>
      <result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
      <result column="file_name" property="fileName" jdbcType="VARCHAR"/>
      <result column="file_type" property="fileType" jdbcType="VARCHAR"/>
      <result column="file_url" property="fileUrl" jdbcType="VARCHAR"/>
      <result column="file_size" property="fileSize" jdbcType="BIGINT"/>
      <result column="resource_id" property="resourceId" jdbcType="INTEGER"/>
      <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>

  </resultMap>
  <sql id="Base_Column_List" >
    id, pcloud_robot_id, pcloud_classify_id, reply_type, content, pic_url, file_name, file_type, file_url,
    file_size, resource_id, create_time
  </sql>

    <!--批量插入-->
    <insert id="batchInsert"  parameterType="PcloudRobotWelcome" useGeneratedKeys="true" keyProperty="id">
        insert into pcloud_robot_welcome (
        pcloud_robot_id,
        pcloud_classify_id,
        reply_type,
        content,
        pic_url,
        file_name,
        file_type,
        file_url,
        file_size,
        resource_id,
        create_time
        ) values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.pcloudRobotId,jdbcType=BIGINT},
            #{item.pcloudClassifyId,jdbcType=BIGINT},
            #{item.replyType,jdbcType=INTEGER},
            #{item.content,jdbcType=VARCHAR},
            #{item.picUrl,jdbcType=VARCHAR},
            #{item.fileName,jdbcType=VARCHAR},
            #{item.fileType,jdbcType=VARCHAR},
            #{item.fileUrl,jdbcType=VARCHAR},
            #{item.fileSize,jdbcType=BIGINT},
            #{item.resourceId,jdbcType=BIGINT},
            NOW()
            )
        </foreach>
    </insert>

    <delete id="deleteByPcloudRobotId" parameterType="long">
        delete from pcloud_robot_welcome
        where pcloud_robot_id = #{pcloudRobotId}
    </delete>

    <delete id="deleteByPcloudClassifyId" parameterType="long">
        delete from pcloud_robot_welcome
        where pcloud_classify_id = #{pcloudClassifyId}
    </delete>

    <select id="getRobotWelcomeListByPcloudRobotId" parameterType="long" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from pcloud_robot_welcome
        where pcloud_robot_id = #{pcloudRobotId}
    </select>

    <select id="getRobotWelcomeListByPcloudClassifyId" parameterType="long" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/>
        from pcloud_robot_welcome
        where pcloud_classify_id = #{pcloudClassifyId}
    </select>
</mapper>