<?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.TGuijiLibraryBaseinfoMapper">

    <resultMap type="TGuijiLibraryBaseinfo" id="TGuijiLibraryBaseinfoResult">
        <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="idcardno"    column="idcardno"    />
        <result property="sex"    column="sex"    />
        <result property="birthday"    column="birthday"    />
        <result property="address"    column="address"    />
        <result property="enddate"    column="enddate"    />
    </resultMap>

    <sql id="selectTGuijiLibraryBaseinfoVo">
        select id, create_time, cd_time, cd_batch, cd_operation, cd_source, cardno, name, idcardno, sex, birthday, address, enddate from t_guiji_library_baseinfo
    </sql>

    <select id="selectTGuijiLibraryBaseinfoList" parameterType="TGuijiLibraryBaseinfo" resultMap="TGuijiLibraryBaseinfoResult">
        <include refid="selectTGuijiLibraryBaseinfoVo"/>
        <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="idcardno != null  and idcardno != ''"> and idcardno = #{idcardno}</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="birthday != null  and birthday != ''"> and birthday = #{birthday}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="enddate != null  and enddate != ''"> and enddate = #{enddate}</if>
        </where>
        order by create_time desc
    </select>

    <select id="selectTGuijiLibraryBaseinfoById" parameterType="String" resultMap="TGuijiLibraryBaseinfoResult">
        <include refid="selectTGuijiLibraryBaseinfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertTGuijiLibraryBaseinfo" parameterType="TGuijiLibraryBaseinfo">
        insert into t_guiji_library_baseinfo
        <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="idcardno != null">idcardno,</if>
            <if test="sex != null">sex,</if>
            <if test="birthday != null">birthday,</if>
            <if test="address != null">address,</if>
            <if test="enddate != null">enddate,</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="idcardno != null">#{idcardno},</if>
            <if test="sex != null">#{sex},</if>
            <if test="birthday != null">#{birthday},</if>
            <if test="address != null">#{address},</if>
            <if test="enddate != null">#{enddate},</if>
         </trim>
    </insert>

    <update id="updateTGuijiLibraryBaseinfo" parameterType="TGuijiLibraryBaseinfo">
        update t_guiji_library_baseinfo
        <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="idcardno != null">idcardno = #{idcardno},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="birthday != null">birthday = #{birthday},</if>
            <if test="address != null">address = #{address},</if>
            <if test="enddate != null">enddate = #{enddate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTGuijiLibraryBaseinfoById" parameterType="String">
        delete from t_guiji_library_baseinfo where id = #{id}
    </delete>

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

</mapper>
