<?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.reading.dao.impl.BookGroupCollectionDaoImpl">
    <resultMap id="BaseResultMap" type="com.pcloud.book.reading.entity.BookGroupCollection">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="amount" property="amount" jdbcType="DECIMAL"/>
        <result column="status" property="status" jdbcType="BIT"/>
        <result column="transfer_id" property="transferId" jdbcType="VARCHAR"/>
        <result column="collection_robot_id" property="collectionRobotId" jdbcType="VARCHAR"/>
        <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
    id, amount, status, transfer_id, collection_robot_id, create_user, create_time, update_user, 
    update_time
  </sql>

    <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>
        from book_group_collection
        where id = #{id,jdbcType=INTEGER}
    </select>

    <select id="getByTransferId"
            resultType="com.pcloud.book.reading.entity.BookGroupCollection">
        select
        <include refid="Base_Column_List"/>
        from book_group_collection
        where transfer_id = #{transferId,jdbcType=VARCHAR}
    </select>

    <delete id="deleteById" parameterType="java.lang.Integer">
    delete from book_group_collection
    where id = #{id,jdbcType=INTEGER}
  </delete>

    <insert id="insert" parameterType="com.pcloud.book.reading.entity.BookGroupCollection">
    insert into book_group_collection (id, amount, status, 
      transfer_id, collection_robot_id, create_user, 
      create_time, update_user, update_time
      )
    values (#{id,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, #{status,jdbcType=BIT}, 
      #{transferId,jdbcType=VARCHAR}, #{collectionRobotId,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}
      )
  </insert>

    <update id="update"
            parameterType="com.pcloud.book.reading.entity.BookGroupCollection">
        update book_group_collection
        <set>
            <if test="amount != null">
                amount = #{amount,jdbcType=DECIMAL},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=BIT},
            </if>
            <if test="transferId != null">
                transfer_id = #{transferId,jdbcType=VARCHAR},
            </if>
            <if test="collectionRobotId != null">
                collection_robot_id = #{collectionRobotId,jdbcType=VARCHAR},
            </if>
            <if test="createUser != null">
                create_user = #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                update_user = #{updateUser,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

</mapper>