<?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.hanserwei.hannote.note.biz.domain.mapper.NoteLikeDOMapper">
  <resultMap id="BaseResultMap" type="com.hanserwei.hannote.note.biz.domain.dataobject.NoteLikeDO">
    <!--@mbg.generated-->
    <!--@Table t_note_like-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="user_id" jdbcType="BIGINT" property="userId" />
    <result column="note_id" jdbcType="BIGINT" property="noteId" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="status" jdbcType="TINYINT" property="status" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, user_id, note_id, create_time, `status`
  </sql>

  <insert id="insertOrUpdate" parameterType="com.hanserwei.hannote.note.biz.domain.dataobject.NoteLikeDO">
      INSERT INTO t_note_like (user_id, note_id, create_time, status)
      VALUES (#{userId}, #{noteId}, #{createTime}, #{status})
      ON DUPLICATE KEY UPDATE
      create_time = #{createTime}, status = #{status};
    </insert>

    <insert id="batchInsertOrUpdate" parameterType="list">
        INSERT INTO t_note_like (user_id, note_id, status, create_time)
        VALUES
        <foreach item="item" collection="noteLikeDOS" separator=",">
            (#{item.userId}, #{item.noteId}, #{item.status}, #{item.createTime})
        </foreach>
        ON DUPLICATE KEY UPDATE status = VALUES(status)
    </insert>
</mapper>