<?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.xinelu.manage.mapper.projectbatch.ProjectBatchMapper">

    <resultMap id="BaseResultMap" type="com.xinelu.manage.domain.projectbatch.ProjectBatch">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="patientId" column="patient_id" jdbcType="BIGINT"/>
            <result property="patientName" column="patient_name" jdbcType="VARCHAR"/>
            <result property="patientPhone" column="patient_phone" jdbcType="VARCHAR"/>
            <result property="birthDate" column="birth_date" jdbcType="DATE"/>
            <result property="cardNo" column="card_no" jdbcType="VARCHAR"/>
            <result property="sex" column="sex" jdbcType="VARCHAR"/>
            <result property="batchName" column="batch_name" jdbcType="VARCHAR"/>
            <result property="batchCode" column="batch_code" jdbcType="VARCHAR"/>
            <result property="batchSort" column="batch_sort" jdbcType="INTEGER"/>
            <result property="batchRemark" column="batch_remark" jdbcType="VARCHAR"/>
            <result property="batchDate" column="batch_date" jdbcType="TIMESTAMP"/>
            <result property="delFlag" column="del_flag" jdbcType="TINYINT"/>
            <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,patient_id,patient_name,
        patient_phone,birth_date,card_no,
        sex,batch_name,batch_code,
        batch_sort,batch_remark,batch_date,
        del_flag,create_by,create_time,
        update_by,update_time
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from project_batch
        where  id = #{id,jdbcType=BIGINT} 
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from project_batch
        where  id = #{id,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.manage.domain.projectbatch.ProjectBatch" useGeneratedKeys="true">
        insert into project_batch
        ( id,patient_id,patient_name
        ,patient_phone,birth_date,card_no
        ,sex,batch_name,batch_code
        ,batch_sort,batch_remark,batch_date
        ,del_flag,create_by,create_time
        ,update_by,update_time)
        values (#{id,jdbcType=BIGINT},#{patientId,jdbcType=BIGINT},#{patientName,jdbcType=VARCHAR}
        ,#{patientPhone,jdbcType=VARCHAR},#{birthDate,jdbcType=DATE},#{cardNo,jdbcType=VARCHAR}
        ,#{sex,jdbcType=VARCHAR},#{batchName,jdbcType=VARCHAR},#{batchCode,jdbcType=VARCHAR}
        ,#{batchSort,jdbcType=INTEGER},#{batchRemark,jdbcType=VARCHAR},#{batchDate,jdbcType=TIMESTAMP}
        ,#{delFlag,jdbcType=TINYINT},#{createBy,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}
        ,#{updateBy,jdbcType=VARCHAR},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.xinelu.manage.domain.projectbatch.ProjectBatch" useGeneratedKeys="true">
        insert into project_batch
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="patientId != null">patient_id,</if>
                <if test="patientName != null">patient_name,</if>
                <if test="patientPhone != null">patient_phone,</if>
                <if test="birthDate != null">birth_date,</if>
                <if test="cardNo != null">card_no,</if>
                <if test="sex != null">sex,</if>
                <if test="batchName != null">batch_name,</if>
                <if test="batchCode != null">batch_code,</if>
                <if test="batchSort != null">batch_sort,</if>
                <if test="batchRemark != null">batch_remark,</if>
                <if test="batchDate != null">batch_date,</if>
                <if test="delFlag != null">del_flag,</if>
                <if test="createBy != null">create_by,</if>
                <if test="createTime != null">create_time,</if>
                <if test="updateBy != null">update_by,</if>
                <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="patientId != null">#{patientId,jdbcType=BIGINT},</if>
                <if test="patientName != null">#{patientName,jdbcType=VARCHAR},</if>
                <if test="patientPhone != null">#{patientPhone,jdbcType=VARCHAR},</if>
                <if test="birthDate != null">#{birthDate,jdbcType=DATE},</if>
                <if test="cardNo != null">#{cardNo,jdbcType=VARCHAR},</if>
                <if test="sex != null">#{sex,jdbcType=VARCHAR},</if>
                <if test="batchName != null">#{batchName,jdbcType=VARCHAR},</if>
                <if test="batchCode != null">#{batchCode,jdbcType=VARCHAR},</if>
                <if test="batchSort != null">#{batchSort,jdbcType=INTEGER},</if>
                <if test="batchRemark != null">#{batchRemark,jdbcType=VARCHAR},</if>
                <if test="batchDate != null">#{batchDate,jdbcType=TIMESTAMP},</if>
                <if test="delFlag != null">#{delFlag,jdbcType=TINYINT},</if>
                <if test="createBy != null">#{createBy,jdbcType=VARCHAR},</if>
                <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
                <if test="updateBy != null">#{updateBy,jdbcType=VARCHAR},</if>
                <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xinelu.manage.domain.projectbatch.ProjectBatch">
        update project_batch
        <set>
                <if test="patientId != null">
                    patient_id = #{patientId,jdbcType=BIGINT},
                </if>
                <if test="patientName != null">
                    patient_name = #{patientName,jdbcType=VARCHAR},
                </if>
                <if test="patientPhone != null">
                    patient_phone = #{patientPhone,jdbcType=VARCHAR},
                </if>
                <if test="birthDate != null">
                    birth_date = #{birthDate,jdbcType=DATE},
                </if>
                <if test="cardNo != null">
                    card_no = #{cardNo,jdbcType=VARCHAR},
                </if>
                <if test="sex != null">
                    sex = #{sex,jdbcType=VARCHAR},
                </if>
                <if test="batchName != null">
                    batch_name = #{batchName,jdbcType=VARCHAR},
                </if>
                <if test="batchCode != null">
                    batch_code = #{batchCode,jdbcType=VARCHAR},
                </if>
                <if test="batchSort != null">
                    batch_sort = #{batchSort,jdbcType=INTEGER},
                </if>
                <if test="batchRemark != null">
                    batch_remark = #{batchRemark,jdbcType=VARCHAR},
                </if>
                <if test="batchDate != null">
                    batch_date = #{batchDate,jdbcType=TIMESTAMP},
                </if>
                <if test="delFlag != null">
                    del_flag = #{delFlag,jdbcType=TINYINT},
                </if>
                <if test="createBy != null">
                    create_by = #{createBy,jdbcType=VARCHAR},
                </if>
                <if test="createTime != null">
                    create_time = #{createTime,jdbcType=TIMESTAMP},
                </if>
                <if test="updateBy != null">
                    update_by = #{updateBy,jdbcType=VARCHAR},
                </if>
                <if test="updateTime != null">
                    update_time = #{updateTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xinelu.manage.domain.projectbatch.ProjectBatch">
        update project_batch
        set 
            patient_id =  #{patientId,jdbcType=BIGINT},
            patient_name =  #{patientName,jdbcType=VARCHAR},
            patient_phone =  #{patientPhone,jdbcType=VARCHAR},
            birth_date =  #{birthDate,jdbcType=DATE},
            card_no =  #{cardNo,jdbcType=VARCHAR},
            sex =  #{sex,jdbcType=VARCHAR},
            batch_name =  #{batchName,jdbcType=VARCHAR},
            batch_code =  #{batchCode,jdbcType=VARCHAR},
            batch_sort =  #{batchSort,jdbcType=INTEGER},
            batch_remark =  #{batchRemark,jdbcType=VARCHAR},
            batch_date =  #{batchDate,jdbcType=TIMESTAMP},
            del_flag =  #{delFlag,jdbcType=TINYINT},
            create_by =  #{createBy,jdbcType=VARCHAR},
            create_time =  #{createTime,jdbcType=TIMESTAMP},
            update_by =  #{updateBy,jdbcType=VARCHAR},
            update_time =  #{updateTime,jdbcType=TIMESTAMP}
        where   id = #{id,jdbcType=BIGINT} 
    </update>
</mapper>
