<?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.PcloudRobotWakeupClassifyMapper" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.guide.entity.PcloudRobotWakeupClassify" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="wake_up_id" property="wakeUpId" jdbcType="INTEGER" />
    <result column="robot_classify_id" property="robotClassifyId" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, wake_up_id, robot_classify_id,create_time, update_time
  </sql>

  <insert id="insert" parameterType="com.pcloud.book.guide.entity.PcloudRobotWakeupClassify" >
    insert into pcloud_robot_wakeup_classify (wake_up_id, robot_classify_id, create_time
      )
    values (#{wakeUpId,jdbcType=INTEGER}, #{robotClassifyId,jdbcType=INTEGER},
       #{createTime,jdbcType=TIMESTAMP}
      )
  </insert>

  <insert id="batchInsert" parameterType="com.pcloud.book.guide.entity.PcloudRobotWakeupClassify">
    insert into  pcloud_robot_wakeup_classify (wake_up_id, robot_classify_id, create_time
    )
    values
    <foreach collection="list" item="item" index="index" separator=",">
      (
      #{item.wakeUpId},
      #{item.robotClassifyId},
      #{item.createTime}
      )
    </foreach>
  </insert>


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

  <select id="getRobotClassifyByWakeUpId" parameterType="integer" resultType="com.pcloud.book.pcloudKeyword.dto.RobotClassifyDTO">
    select
    prwc.robot_classify_id classifyId,
    prc.classify_name classifyName
    from
    pcloud_robot_wakeup_classify prwc
    left join pcloud_robot_classify prc
    on prwc.robot_classify_id =  prc.id
    where prwc.wake_up_id = #{_parameter}
  </select>

  <select id="deleteByWakeUpId" parameterType="integer">
    delete
    from
    pcloud_robot_wakeup_classify
    where
    wake_up_id = #{wakeUpId}
  </select>


</mapper>