<?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.book.dao.impl.EdtionRecordDaoImpl">
  <resultMap id="BaseResultMap" type="com.pcloud.book.book.entity.EditionRecord">
    <constructor>
      <idArg column="id" javaType="java.lang.Long" jdbcType="BIGINT" />
      <arg column="book_id" javaType="java.lang.Long" jdbcType="BIGINT" />
      <arg column="edition_year" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="edition" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
      <arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
      <arg column="update_user" javaType="java.lang.Integer" jdbcType="INTEGER" />
    </constructor>
  </resultMap>
  <sql id="Base_Column_List">
    id, book_id, edition_year, edition, create_time, update_time, update_user
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from edition_record
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from edition_record
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.pcloud.book.book.entity.EditionRecord">
    insert into edition_record (id, book_id, edition_year, 
      edition, create_time, update_time, 
      update_user)
    values (#{id,jdbcType=BIGINT}, #{bookId,jdbcType=BIGINT}, #{editionYear,jdbcType=VARCHAR},
      #{edition,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{updateUser,jdbcType=INTEGER})
  </insert>

  <insert id="batchInsert" parameterType="list">
    insert into edition_record (book_id, edition_year,
    edition, create_time, update_time,update_user
    )
    values
    <foreach collection="list" index="index" item="item" separator=",">
      (#{item.bookId,jdbcType=BIGINT}, #{item.editionYear,jdbcType=VARCHAR},
      #{item.edition,jdbcType=INTEGER}, now(),now(),#{item.updateUser}
      )
    </foreach>
  </insert>

  <insert id="insertSelective" parameterType="com.pcloud.book.book.entity.EditionRecord">
    insert into edition_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="bookId != null">
        book_id,
      </if>
      <if test="editionYear != null">
        edition_year,
      </if>
      <if test="edition != null">
        edition,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="updateUser != null">
        update_user,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="bookId != null">
        #{bookId,jdbcType=INTEGER},
      </if>
      <if test="editionYear != null">
        #{editionYear,jdbcType=VARCHAR},
      </if>
      <if test="edition != null">
        #{edition,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        #{updateUser,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.book.entity.EditionRecord">
    update edition_record
    <set>
      <if test="bookId != null">
        book_id = #{bookId,jdbcType=INTEGER},
      </if>
      <if test="editionYear != null">
        edition_year = #{editionYear,jdbcType=VARCHAR},
      </if>
      <if test="edition != null">
        edition = #{edition,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null">
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pcloud.book.book.entity.EditionRecord">
    update edition_record
    set book_id = #{bookId,jdbcType=BIGINT},
      edition_year = #{editionYear,jdbcType=VARCHAR},
      edition = #{edition,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>