<?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.guide.mapper.PcloudWakeupMessageMapper" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.guide.entity.PcloudWakeupMessage" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="text_content" property="textContent" jdbcType="VARCHAR" />
    <result column="img_url" property="imgUrl" jdbcType="VARCHAR" />
    <result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
    <result column="file_name" property="fileName" jdbcType="VARCHAR" />
    <result column="seq_num" property="seqNum" jdbcType="BIT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <resultMap id="BaseResultMap4VO" type="com.pcloud.book.guide.vo.RobotWakeUpMsgVO" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="text_content" property="content" jdbcType="VARCHAR" />
    <result column="img_url" property="picUrl" jdbcType="VARCHAR" />
    <result column="file_url" property="fileUrl" jdbcType="VARCHAR" />
    <result column="file_name" property="fileName" jdbcType="VARCHAR" />
    <result column="seq_num" property="seqNum" jdbcType="BIT" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, type, text_content, img_url, file_url, file_name, seq_num, create_time, update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from pcloud_wakeup_message
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from pcloud_wakeup_message
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.pcloud.book.guide.entity.PcloudWakeupMessage" >
    insert into pcloud_wakeup_message (id, type, text_content, 
      img_url, file_url, file_name, 
      seq_num, create_time, update_time
      )
    values (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{textContent,jdbcType=VARCHAR}, 
      #{imgUrl,jdbcType=VARCHAR}, #{fileUrl,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, 
      #{seqNum,jdbcType=BIT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.pcloud.book.guide.entity.PcloudWakeupMessage" keyProperty="id" useGeneratedKeys="true">
    insert into pcloud_wakeup_message
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="textContent != null" >
        text_content,
      </if>
      <if test="imgUrl != null" >
        img_url,
      </if>
      <if test="fileUrl != null" >
        file_url,
      </if>
      <if test="fileName != null" >
        file_name,
      </if>
      <if test="seqNum != null" >
        seq_num,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="textContent != null" >
        #{textContent,jdbcType=VARCHAR},
      </if>
      <if test="imgUrl != null" >
        #{imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="fileUrl != null" >
        #{fileUrl,jdbcType=VARCHAR},
      </if>
      <if test="fileName != null" >
        #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="seqNum != null" >
        #{seqNum,jdbcType=BIT},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

    <insert id="batchInsert" parameterType="com.pcloud.book.guide.entity.PcloudWakeupMessage">
      insert into pcloud_wakeup_message ( type, text_content,
      img_url, file_url, file_name,
      seq_num, create_time, update_time,wake_up_id
      )
      values
      <foreach collection="list" item="item" index="index" separator=",">
      (
        #{item.type,jdbcType=VARCHAR}, #{item.textContent,jdbcType=VARCHAR},
        #{item.imgUrl,jdbcType=VARCHAR}, #{item.fileUrl,jdbcType=VARCHAR}, #{item.fileName,jdbcType=VARCHAR},
        #{item.seqNum,jdbcType=BIT}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP},
        #{item.wakeUpId}
        )
      </foreach>
    </insert>

    <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.guide.entity.PcloudWakeupMessage" >
    update pcloud_wakeup_message
    <set >
      <if test="type != null" >
        type = #{type,jdbcType=VARCHAR},
      </if>
      <if test="textContent != null" >
        text_content = #{textContent,jdbcType=VARCHAR},
      </if>
      <if test="imgUrl != null" >
        img_url = #{imgUrl,jdbcType=VARCHAR},
      </if>
      <if test="fileUrl != null" >
        file_url = #{fileUrl,jdbcType=VARCHAR},
      </if>
      <if test="fileName != null" >
        file_name = #{fileName,jdbcType=VARCHAR},
      </if>
      <if test="seqNum != null" >
        seq_num = #{seqNum,jdbcType=BIT},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pcloud.book.guide.entity.PcloudWakeupMessage" >
    update pcloud_wakeup_message
    set type = #{type,jdbcType=VARCHAR},
      text_content = #{textContent,jdbcType=VARCHAR},
      img_url = #{imgUrl,jdbcType=VARCHAR},
      file_url = #{fileUrl,jdbcType=VARCHAR},
      file_name = #{fileName,jdbcType=VARCHAR},
      seq_num = #{seqNum,jdbcType=BIT},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

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

  <select id="selectAll" resultMap="BaseResultMap">
    select
      <include refid="Base_Column_List"/>
    from
        pcloud_wakeup_message
  </select>

  <select id="getAllClassifyInfo" resultType="java.lang.Integer">
    SELECT
        robot_type
    FROM pcloud_robot
    WHERE wake_up = 1
  </select>

  <select id="countAll" resultType="java.lang.Integer">
    select  count(0) from pcloud_robot_classify
  </select>

  <select id="selectByWakeUpId" resultMap="BaseResultMap4VO" parameterType="integer">
    select
    id, type, text_content, img_url, file_url, file_name, seq_num
    from
    pcloud_wakeup_message
    where
    wake_up_id = #{_parameter}
  </select>


  <delete id="delectByWakeUpId" parameterType="integer">
    delete
    from
    pcloud_wakeup_message
    where
    wake_up_id = #{wakeUpId}

  </delete>
</mapper>