<?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.fdkankan.ucenter.mapper.ISceneUpgradeMapper">

  <insert id="transferScenePlus" parameterType="java.lang.String">
    INSERT INTO t_scene_plus (
    `num`,
    `user_id`,
    `camera_id`,
    `phone_id`,
    `title`,
    `description`,
    `scene_status`,
    `scene_source`,
    `pay_status`,
    `scene_type`,
    `recommend`,
    `create_time`,
    `update_time`,
    `rec_status`
  )
  SELECT
    p.`num`,
    p.`user_id`,
    p.`camera_id`,
    p.`phone_id`,
    p.`scene_name`,
    p.`scene_dec`,
    p.`status`,
    p.`scene_source`,
    p.`pay_status`,
    p.`scene_type`,
    p.`recommend`,
    p.`create_time`,
    p.`update_time`,
     p.rec_status
  FROM
    t_scene_pro p
  WHERE p.num = #{num};
  </insert>

  <insert id="transferScenePlusExt">
    INSERT INTO t_scene_plus_ext (
    plus_id,
    data_source,
    web_site,
    thumb,
    scene_scheme,
    SPACE,
    ecs,
    shoot_count,
    view_count,
    gps,
    ALGORITHM,
    firmware_version,
    build_type,
    create_time,
    update_time,
    rec_status,
    scene_resolution,
    scene_from,
    scene_kind,
    model_kind,
    videos,
    algorithm_time,
    is_obj
  )
  SELECT
    #{scenePlusId},
    p.`data_source`,
    p.`web_site`,
    p.`thumb`,
    p.`scene_scheme`,
    p.`space`,
    p.`ecs`,
    p.`shoot_count`,
    p.`view_count`,
    p.`gps`,
    p.`algorithm`,
    p.`firmware_version`,
    p.`build_type`,
    p.`create_time`,
    p.`update_time`,
    p.rec_status ,
    CASE
      WHEN p.scene_source = 1 THEN '2k'
      WHEN p.scene_source = 2 THEN '1k'
      WHEN p.scene_source = 3 THEN '4k'
      WHEN p.scene_source = 4 THEN '4k'
      ELSE NULL
     END AS scene_resolution,
    CASE
      WHEN p.scene_source = 1 THEN 'pro'
      WHEN p.scene_source = 2 THEN 'lite'
      WHEN p.scene_source = 3 THEN 'minion'
      WHEN p.scene_source = 4 THEN 'laser'
      ELSE NULL
     END AS scene_from,
    #{sceneKind} scene_kind,
    'dam',
    p.videos,
    p.`create_time`,
    p.is_obj
  FROM
    t_scene_pro p
  WHERE p.num = #{num}
  </insert>


  <delete id="deleteScenePlus" parameterType="java.lang.String">
    delete from t_scene_plus where num = #{num}
  </delete>

  <delete id="deleteScenePlusExt" parameterType="java.lang.Long">
    delete from t_scene_plus_ext where plus_id = #{scenePlusId}
  </delete>

</mapper>
