<?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.persagy.dmp.rwd.migrate.dao.SyncDataMapper">
  <resultMap id="BaseResultMap" type="com.persagy.dmp.rwd.migrate.entity.SyncData">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <id column="table_name" jdbcType="VARCHAR" property="tableName" />
    <result column="target_id" jdbcType="VARCHAR" property="targetId" />
    <result column="object_type" jdbcType="VARCHAR" property="objectType" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="project_id" jdbcType="VARCHAR" property="projectId" />
    <result column="sign" jdbcType="INTEGER" property="sign" />
    <result column="ops" jdbcType="VARCHAR" property="ops" />
    <result column="ops_name" jdbcType="VARCHAR" property="opsName" />
    <result column="from_id" jdbcType="VARCHAR" property="fromId" />
    <result column="to_id" jdbcType="VARCHAR" property="toId" />
    <result column="error" jdbcType="VARCHAR" property="error" />
    <result column="class_code" jdbcType="VARCHAR" property="classCode" />
    <result column="local_name" jdbcType="VARCHAR" property="localName" />
    <result column="local_id" jdbcType="VARCHAR" property="localId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="creator" jdbcType="VARCHAR" property="creator" />
    <result column="creation_time" jdbcType="CHAR" property="creationTime" />
    <result column="modifier" jdbcType="VARCHAR" property="modifier" />
    <result column="modified_time" jdbcType="CHAR" property="modifiedTime" />
    <result column="valid" jdbcType="TINYINT" property="valid" />
    <result column="ts" jdbcType="TIMESTAMP" property="ts" />
  </resultMap>
  <sql id="Base_Column_List">
    id, table_name, target_id, object_type, `type`, project_id, sign, ops, ops_name, from_id, to_id,
    error, class_code, local_name, local_id, `name`, code,  creator, creation_time,
    modifier, modified_time, `valid`, ts
  </sql>

  <insert id="save">
    insert into dt_sync_data
     (id,table_name,target_id, object_type, `type`,
      project_id, sign, ops, 
      ops_name, from_id, to_id, 
      error, class_code, local_name, 
      local_id, `name`, code,
      creator, creation_time,
      modifier, modified_time)
    VALUES
    <foreach collection="vos" item="vo" open="(" close=")" separator="),(">
      #{vo.id},#{vo.tableName},#{vo.targetId},#{vo.objectType},#{vo.type},
      #{vo.projectId},#{vo.sign},#{vo.ops},
      #{vo.opsName},#{vo.fromId},#{vo.toId},
      #{vo.error},#{vo.classCode},#{vo.localName},
      #{vo.localId},#{vo.name},#{vo.code},
      #{vo.creator},#{vo.creationTime},
      #{vo.modifier},#{vo.modifiedTime}
    </foreach>
    ON DUPLICATE KEY UPDATE
    type = VALUES(type), ops = VALUES(ops), ops_name = VALUES(ops_name),
    from_id = VALUES(from_id), to_id = VALUES(to_id), error = VALUES(error),
    class_code = VALUES(class_code), local_name = VALUES(local_name), local_id = VALUES(local_id),
    `name` = VALUES(name),code = VALUES(code),
    modifier = VALUES(modifier), modified_time = VALUES(modified_time)
  </insert>

</mapper>