<?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.sooka.system.mapper.TGuijiLibraryBorrowMapper">

    <resultMap type="TGuijiLibraryBorrow" id="TGuijiLibraryBorrowResult">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="cdTime"    column="cd_time"    />
        <result property="cdBatch"    column="cd_batch"    />
        <result property="cdOperation"    column="cd_operation"    />
        <result property="cdSource"    column="cd_source"    />
        <result property="cardno"    column="cardno"    />
        <result property="name"    column="name"    />
        <result property="barcode"    column="barcode"    />
        <result property="title"    column="title"    />
        <result property="operationdate"    column="operationdate"    />
    </resultMap>

    <sql id="selectTGuijiLibraryBorrowVo">
        select id, create_time, cd_time, cd_batch, cd_operation, cd_source, cardno, name, barcode, title, operationdate from t_guiji_library_borrow
    </sql>

    <select id="selectTGuijiLibraryBorrowList" parameterType="TGuijiLibraryBorrow" resultMap="TGuijiLibraryBorrowResult">
        <include refid="selectTGuijiLibraryBorrowVo"/>
        <where>
            <if test="cdTime != null  and cdTime != ''"> and cd_time = #{cdTime}</if>
            <if test="cdBatch != null  and cdBatch != ''"> and cd_batch = #{cdBatch}</if>
            <if test="cdOperation != null  and cdOperation != ''"> and cd_operation = #{cdOperation}</if>
            <if test="cdSource != null  and cdSource != ''"> and cd_source = #{cdSource}</if>
            <if test="cardno != null  and cardno != ''"> and cardno = #{cardno}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="barcode != null  and barcode != ''"> and barcode = #{barcode}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="operationdate != null  and operationdate != ''"> and operationdate = #{operationdate}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectTGuijiLibraryBorrowById" parameterType="String" resultMap="TGuijiLibraryBorrowResult">
        <include refid="selectTGuijiLibraryBorrowVo"/>
        where id = #{id}
    </select>

    <insert id="insertTGuijiLibraryBorrow" parameterType="TGuijiLibraryBorrow">
        insert into t_guiji_library_borrow
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="cdTime != null">cd_time,</if>
            <if test="cdBatch != null">cd_batch,</if>
            <if test="cdOperation != null">cd_operation,</if>
            <if test="cdSource != null">cd_source,</if>
            <if test="cardno != null">cardno,</if>
            <if test="name != null">name,</if>
            <if test="barcode != null">barcode,</if>
            <if test="title != null">title,</if>
            <if test="operationdate != null">operationdate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="cdTime != null">#{cdTime},</if>
            <if test="cdBatch != null">#{cdBatch},</if>
            <if test="cdOperation != null">#{cdOperation},</if>
            <if test="cdSource != null">#{cdSource},</if>
            <if test="cardno != null">#{cardno},</if>
            <if test="name != null">#{name},</if>
            <if test="barcode != null">#{barcode},</if>
            <if test="title != null">#{title},</if>
            <if test="operationdate != null">#{operationdate},</if>
         </trim>
    </insert>

    <update id="updateTGuijiLibraryBorrow" parameterType="TGuijiLibraryBorrow">
        update t_guiji_library_borrow
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="cdTime != null">cd_time = #{cdTime},</if>
            <if test="cdBatch != null">cd_batch = #{cdBatch},</if>
            <if test="cdOperation != null">cd_operation = #{cdOperation},</if>
            <if test="cdSource != null">cd_source = #{cdSource},</if>
            <if test="cardno != null">cardno = #{cardno},</if>
            <if test="name != null">name = #{name},</if>
            <if test="barcode != null">barcode = #{barcode},</if>
            <if test="title != null">title = #{title},</if>
            <if test="operationdate != null">operationdate = #{operationdate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTGuijiLibraryBorrowById" parameterType="String">
        delete from t_guiji_library_borrow where id = #{id}
    </delete>

    <delete id="deleteTGuijiLibraryBorrowByIds" parameterType="String">
        delete from t_guiji_library_borrow where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>
