<?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.PcloudRobotWakeupMapper" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.guide.entity.PcloudRobotWakeup" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="start_time" property="startTime" jdbcType="TIMESTAMP" />
    <result column="cycle" property="cycle" jdbcType="INTEGER" />
    <result column="last" property="last" 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, start_time, cycle, last, create_time, update_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from pcloud_robot_wakeup
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from pcloud_robot_wakeup
    where id = #{id,jdbcType=INTEGER}
  </delete>
    <insert id="insert" parameterType="com.pcloud.book.guide.entity.PcloudRobotWakeup" >
    insert into pcloud_robot_wakeup (id, start_time, cycle, 
      last, create_time, update_time
      )
    values (#{id,jdbcType=INTEGER}, #{startTime,jdbcType=TIMESTAMP}, #{cycle,jdbcType=INTEGER}, 
      #{last,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.pcloud.book.guide.entity.PcloudRobotWakeup" >
    insert into pcloud_robot_wakeup
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="startTime != null" >
        start_time,
      </if>
      <if test="cycle != null" >
        cycle,
      </if>
      <if test="last != null" >
        last,
      </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="startTime != null" >
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="cycle != null" >
        #{cycle,jdbcType=INTEGER},
      </if>
      <if test="last != null" >
        #{last,jdbcType=INTEGER},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.guide.entity.PcloudRobotWakeup" >
    update pcloud_robot_wakeup
    <set >
      <if test="startTime != null" >
        start_time = #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="cycle != null" >
        cycle = #{cycle,jdbcType=INTEGER},
      </if>
      <if test="last != null" >
        last = #{last,jdbcType=INTEGER},
      </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.PcloudRobotWakeup" >
    update pcloud_robot_wakeup
    set start_time = #{startTime,jdbcType=TIMESTAMP},
      cycle = #{cycle,jdbcType=INTEGER},
      last = #{last,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

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

  <select id="selectOne" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from pcloud_robot_wakeup
    limit 1
  </select>

  <select id="listAllRobot" resultType="java.lang.String">
    SELECT wx_id FROM pcloud_robot WHERE wake_up=1
  </select>
  <select id="listAllClassify"
          resultType="com.pcloud.book.pcloudkeyword.facade.response.PcloudRobotClassifyResponseVO">
    SELECT
    id,
    classify_name classifyName
    FROM pcloud_robot_classify WHERE id IN (SELECT DISTINCT robot_type FROM pcloud_robot )
    AND is_delete = 0
  </select>


</mapper>