<?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="cn.cecep.talroad.mapper.MAmVideoInfoOperationLogMapper">
  <resultMap id="BaseResultMap" type="cn.cecep.talroad.domain.MAmVideoInfoOperationLog">
    <!--@mbg.generated-->
    <!--@Table m_am_video_info_operation_log-->
    <id column="log_id" jdbcType="VARCHAR" property="logId" />
    <result column="operation_time" jdbcType="TIMESTAMP" property="operationTime" />
    <result column="video_station_name" jdbcType="VARCHAR" property="videoStationName" />
    <result column="before_modify_name" jdbcType="VARCHAR" property="beforeModifyName" />
    <result column="before_modify_code" jdbcType="VARCHAR" property="beforeModifyCode" />
    <result column="operation_status" jdbcType="VARCHAR" property="operationStatus" />
    <result column="after_modify_name" jdbcType="VARCHAR" property="afterModifyName" />
    <result column="after_modify_code" jdbcType="VARCHAR" property="afterModifyCode" />
    <result column="operator" jdbcType="VARCHAR" property="operator" />
    <result column="operator_id" jdbcType="VARCHAR" property="operatorId" />
    <result column="video_channel" jdbcType="VARCHAR" property="videoChannel" />
    <result column="factory_id" jdbcType="VARCHAR" property="factoryId" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    log_id, operation_time, video_station_name, before_modify_name, before_modify_code, 
    operation_status, after_modify_name, after_modify_code, "operator", operator_id, 
    video_channel, factory_id
  </sql>
  <insert id="insertSelective" parameterType="cn.cecep.talroad.domain.MAmVideoInfoOperationLog">
    <!--@mbg.generated-->
    insert into m_am_video_info_operation_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="logId != null and logId != ''">
        log_id,
      </if>
      <if test="operationTime != null">
        operation_time,
      </if>
      <if test="videoStationName != null and videoStationName != ''">
        video_station_name,
      </if>
      <if test="beforeModifyName != null and beforeModifyName != ''">
        before_modify_name,
      </if>
      <if test="beforeModifyCode != null and beforeModifyCode != ''">
        before_modify_code,
      </if>
      <if test="operationStatus != null and operationStatus != ''">
        operation_status,
      </if>
      <if test="afterModifyName != null and afterModifyName != ''">
        after_modify_name,
      </if>
      <if test="afterModifyCode != null and afterModifyCode != ''">
        after_modify_code,
      </if>
      <if test="operator != null and operator != ''">
        "operator",
      </if>
      <if test="operatorId != null and operatorId != ''">
        operator_id,
      </if>
      <if test="videoChannel != null and videoChannel != ''">
        video_channel,
      </if>
      <if test="factoryId != null and factoryId != ''">
        factory_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="logId != null and logId != ''">
        #{logId,jdbcType=VARCHAR},
      </if>
      <if test="operationTime != null">
        #{operationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="videoStationName != null and videoStationName != ''">
        #{videoStationName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyName != null and beforeModifyName != ''">
        #{beforeModifyName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyCode != null and beforeModifyCode != ''">
        #{beforeModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operationStatus != null and operationStatus != ''">
        #{operationStatus,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyName != null and afterModifyName != ''">
        #{afterModifyName,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyCode != null and afterModifyCode != ''">
        #{afterModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operator != null and operator != ''">
        #{operator,jdbcType=VARCHAR},
      </if>
      <if test="operatorId != null and operatorId != ''">
        #{operatorId,jdbcType=VARCHAR},
      </if>
      <if test="videoChannel != null and videoChannel != ''">
        #{videoChannel,jdbcType=VARCHAR},
      </if>
      <if test="factoryId != null and factoryId != ''">
        #{factoryId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.cecep.talroad.domain.MAmVideoInfoOperationLog">
    <!--@mbg.generated-->
    update m_am_video_info_operation_log
    <set>
      <if test="operationTime != null">
        operation_time = #{operationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="videoStationName != null and videoStationName != ''">
        video_station_name = #{videoStationName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyName != null and beforeModifyName != ''">
        before_modify_name = #{beforeModifyName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyCode != null and beforeModifyCode != ''">
        before_modify_code = #{beforeModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operationStatus != null and operationStatus != ''">
        operation_status = #{operationStatus,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyName != null and afterModifyName != ''">
        after_modify_name = #{afterModifyName,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyCode != null and afterModifyCode != ''">
        after_modify_code = #{afterModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operator != null and operator != ''">
        "operator" = #{operator,jdbcType=VARCHAR},
      </if>
      <if test="operatorId != null and operatorId != ''">
        operator_id = #{operatorId,jdbcType=VARCHAR},
      </if>
      <if test="videoChannel != null and videoChannel != ''">
        video_channel = #{videoChannel,jdbcType=VARCHAR},
      </if>
      <if test="factoryId != null and factoryId != ''">
        factory_id = #{factoryId,jdbcType=VARCHAR},
      </if>
    </set>
    where log_id = #{logId,jdbcType=VARCHAR}
  </update>
  <update id="updateBatch" parameterType="java.util.List">
    <!--@mbg.generated-->
    update m_am_video_info_operation_log
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="operation_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operationTime,jdbcType=TIMESTAMP}
        </foreach>
      </trim>
      <trim prefix="video_station_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.videoStationName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="before_modify_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.beforeModifyName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="before_modify_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.beforeModifyCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="operation_status = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operationStatus,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="after_modify_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.afterModifyName,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="after_modify_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.afterModifyCode,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="&quot;operator&quot; = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operator,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="operator_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operatorId,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="video_channel = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.videoChannel,jdbcType=VARCHAR}
        </foreach>
      </trim>
      <trim prefix="factory_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.factoryId,jdbcType=VARCHAR}
        </foreach>
      </trim>
    </trim>
    where log_id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.logId,jdbcType=VARCHAR}
    </foreach>
  </update>
  <update id="updateBatchSelective" parameterType="java.util.List">
    <!--@mbg.generated-->
    update m_am_video_info_operation_log
    <trim prefix="set" suffixOverrides=",">
      <trim prefix="operation_time = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.operationTime != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operationTime,jdbcType=TIMESTAMP}
          </if>
        </foreach>
      </trim>
      <trim prefix="video_station_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.videoStationName != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.videoStationName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="before_modify_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.beforeModifyName != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.beforeModifyName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="before_modify_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.beforeModifyCode != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.beforeModifyCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="operation_status = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.operationStatus != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operationStatus,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="after_modify_name = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.afterModifyName != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.afterModifyName,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="after_modify_code = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.afterModifyCode != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.afterModifyCode,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="&quot;operator&quot; = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.operator != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operator,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="operator_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.operatorId != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.operatorId,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="video_channel = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.videoChannel != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.videoChannel,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
      <trim prefix="factory_id = case" suffix="end,">
        <foreach collection="list" index="index" item="item">
          <if test="item.factoryId != null">
            when log_id = #{item.logId,jdbcType=VARCHAR} then #{item.factoryId,jdbcType=VARCHAR}
          </if>
        </foreach>
      </trim>
    </trim>
    where log_id in
    <foreach close=")" collection="list" item="item" open="(" separator=", ">
      #{item.logId,jdbcType=VARCHAR}
    </foreach>
  </update>
  <insert id="batchInsert" parameterType="map">
    <!--@mbg.generated-->
    insert into m_am_video_info_operation_log
    (log_id, operation_time, video_station_name, before_modify_name, before_modify_code, 
      operation_status, after_modify_name, after_modify_code, "operator", operator_id, 
      video_channel, factory_id)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.logId,jdbcType=VARCHAR}, #{item.operationTime,jdbcType=TIMESTAMP}, #{item.videoStationName,jdbcType=VARCHAR}, 
        #{item.beforeModifyName,jdbcType=VARCHAR}, #{item.beforeModifyCode,jdbcType=VARCHAR}, 
        #{item.operationStatus,jdbcType=VARCHAR}, #{item.afterModifyName,jdbcType=VARCHAR}, 
        #{item.afterModifyCode,jdbcType=VARCHAR}, #{item.operator,jdbcType=VARCHAR}, #{item.operatorId,jdbcType=VARCHAR}, 
        #{item.videoChannel,jdbcType=VARCHAR}, #{item.factoryId,jdbcType=VARCHAR})
    </foreach>
  </insert>
  <insert id="insertOrUpdate" parameterType="cn.cecep.talroad.domain.MAmVideoInfoOperationLog">
    <!--@mbg.generated-->
    insert into m_am_video_info_operation_log
    (log_id, operation_time, video_station_name, before_modify_name, before_modify_code, 
      operation_status, after_modify_name, after_modify_code, "operator", operator_id, 
      video_channel, factory_id)
    values
    (#{logId,jdbcType=VARCHAR}, #{operationTime,jdbcType=TIMESTAMP}, #{videoStationName,jdbcType=VARCHAR}, 
      #{beforeModifyName,jdbcType=VARCHAR}, #{beforeModifyCode,jdbcType=VARCHAR}, #{operationStatus,jdbcType=VARCHAR}, 
      #{afterModifyName,jdbcType=VARCHAR}, #{afterModifyCode,jdbcType=VARCHAR}, #{operator,jdbcType=VARCHAR}, 
      #{operatorId,jdbcType=VARCHAR}, #{videoChannel,jdbcType=VARCHAR}, #{factoryId,jdbcType=VARCHAR}
      )
    on duplicate key update 
    log_id = #{logId,jdbcType=VARCHAR}, 
    operation_time = #{operationTime,jdbcType=TIMESTAMP}, 
    video_station_name = #{videoStationName,jdbcType=VARCHAR}, 
    before_modify_name = #{beforeModifyName,jdbcType=VARCHAR}, 
    before_modify_code = #{beforeModifyCode,jdbcType=VARCHAR}, 
    operation_status = #{operationStatus,jdbcType=VARCHAR}, 
    after_modify_name = #{afterModifyName,jdbcType=VARCHAR}, 
    after_modify_code = #{afterModifyCode,jdbcType=VARCHAR}, 
    "operator" = #{operator,jdbcType=VARCHAR}, 
    operator_id = #{operatorId,jdbcType=VARCHAR}, 
    video_channel = #{videoChannel,jdbcType=VARCHAR}, 
    factory_id = #{factoryId,jdbcType=VARCHAR}
  </insert>
  <insert id="insertOrUpdateSelective" parameterType="cn.cecep.talroad.domain.MAmVideoInfoOperationLog">
    <!--@mbg.generated-->
    insert into m_am_video_info_operation_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="logId != null and logId != ''">
        log_id,
      </if>
      <if test="operationTime != null">
        operation_time,
      </if>
      <if test="videoStationName != null and videoStationName != ''">
        video_station_name,
      </if>
      <if test="beforeModifyName != null and beforeModifyName != ''">
        before_modify_name,
      </if>
      <if test="beforeModifyCode != null and beforeModifyCode != ''">
        before_modify_code,
      </if>
      <if test="operationStatus != null and operationStatus != ''">
        operation_status,
      </if>
      <if test="afterModifyName != null and afterModifyName != ''">
        after_modify_name,
      </if>
      <if test="afterModifyCode != null and afterModifyCode != ''">
        after_modify_code,
      </if>
      <if test="operator != null and operator != ''">
        "operator",
      </if>
      <if test="operatorId != null and operatorId != ''">
        operator_id,
      </if>
      <if test="videoChannel != null and videoChannel != ''">
        video_channel,
      </if>
      <if test="factoryId != null and factoryId != ''">
        factory_id,
      </if>
    </trim>
    values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="logId != null and logId != ''">
        #{logId,jdbcType=VARCHAR},
      </if>
      <if test="operationTime != null">
        #{operationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="videoStationName != null and videoStationName != ''">
        #{videoStationName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyName != null and beforeModifyName != ''">
        #{beforeModifyName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyCode != null and beforeModifyCode != ''">
        #{beforeModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operationStatus != null and operationStatus != ''">
        #{operationStatus,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyName != null and afterModifyName != ''">
        #{afterModifyName,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyCode != null and afterModifyCode != ''">
        #{afterModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operator != null and operator != ''">
        #{operator,jdbcType=VARCHAR},
      </if>
      <if test="operatorId != null and operatorId != ''">
        #{operatorId,jdbcType=VARCHAR},
      </if>
      <if test="videoChannel != null and videoChannel != ''">
        #{videoChannel,jdbcType=VARCHAR},
      </if>
      <if test="factoryId != null and factoryId != ''">
        #{factoryId,jdbcType=VARCHAR},
      </if>
    </trim>
    on duplicate key update 
    <trim suffixOverrides=",">
      <if test="logId != null and logId != ''">
        log_id = #{logId,jdbcType=VARCHAR},
      </if>
      <if test="operationTime != null">
        operation_time = #{operationTime,jdbcType=TIMESTAMP},
      </if>
      <if test="videoStationName != null and videoStationName != ''">
        video_station_name = #{videoStationName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyName != null and beforeModifyName != ''">
        before_modify_name = #{beforeModifyName,jdbcType=VARCHAR},
      </if>
      <if test="beforeModifyCode != null and beforeModifyCode != ''">
        before_modify_code = #{beforeModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operationStatus != null and operationStatus != ''">
        operation_status = #{operationStatus,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyName != null and afterModifyName != ''">
        after_modify_name = #{afterModifyName,jdbcType=VARCHAR},
      </if>
      <if test="afterModifyCode != null and afterModifyCode != ''">
        after_modify_code = #{afterModifyCode,jdbcType=VARCHAR},
      </if>
      <if test="operator != null and operator != ''">
        "operator" = #{operator,jdbcType=VARCHAR},
      </if>
      <if test="operatorId != null and operatorId != ''">
        operator_id = #{operatorId,jdbcType=VARCHAR},
      </if>
      <if test="videoChannel != null and videoChannel != ''">
        video_channel = #{videoChannel,jdbcType=VARCHAR},
      </if>
      <if test="factoryId != null and factoryId != ''">
        factory_id = #{factoryId,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <select id="selectListByParam" resultMap="BaseResultMap">
    SELECT
    <include refid="Base_Column_List"/>
    FROM m_am_video_info_operation_log
    <where>
      factory_id = #{dto.factoryId}
      <if test="dto.devName != null and dto.devName != ''">
        AND video_station_name LIKE CONCAT('%', #{dto.devName}, '%')
      </if>
      <if test="dto.deviceName != null and dto.deviceName != ''">
        AND (before_modify_name LIKE CONCAT('%', #{dto.deviceName}, '%') OR after_modify_name LIKE CONCAT('%', #{dto.deviceName}, '%'))
      </if>
      <if test="dto.deviceCode != null and dto.deviceCode !=''">
        AND (before_modify_code LIKE CONCAT('%', #{dto.deviceCode}, '%') OR after_modify_code LIKE CONCAT('%', #{dto.deviceCode}, '%'))
      </if>
      <if test="startTime != null">
        AND operation_time &gt;= #{startTime}
      </if>
      <if test="endTime != null">
        AND operation_time &lt;= #{endTime}
      </if>
    </where>
    order by operation_time desc
  </select>
</mapper>