<?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.signpatientinformed.SignPatientInformedMapper">

    <resultMap type="SignPatientInformed" id="SignPatientInformedResult">
            <result property="id" column="id"/>
	        <result property="signPatientRecordId" column="sign_patient_record_id"/>
            <result property="patientId" column="patient_id"/>
            <result property="informedFileName" column="informed_file_name"/>
            <result property="informedFilePath" column="informed_file_path"/>
            <result property="createBy" column="create_by"/>
            <result property="createTime" column="create_time"/>
            <result property="updateBy" column="update_by"/>
            <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectSignPatientInformedVo">
        select id, sign_patient_record_id, patient_id, informed_file_name, informed_file_path, create_by, create_time, update_by, update_time from sign_patient_informed
    </sql>

    <select id="selectSignPatientInformedList" parameterType="SignPatientInformed" resultMap="SignPatientInformedResult">
        <include refid="selectSignPatientInformedVo"/>
        <where>
	        <if test="signPatientRecordId != null ">
		        and sign_patient_record_id = #{signPatientRecordId}
	        </if>
            <if test="patientId != null ">
                and patient_id = #{patientId}
            </if>
        </where>
    </select>

    <select id="selectSignPatientInformedById" parameterType="Long"
            resultMap="SignPatientInformedResult">
            <include refid="selectSignPatientInformedVo"/>
            where id = #{id}
    </select>

    <insert id="insertSignPatientInformed" parameterType="SignPatientInformed" useGeneratedKeys="true"
            keyProperty="id">
        insert into sign_patient_informed
        <trim prefix="(" suffix=")" suffixOverrides=",">
	        <if test="signPatientRecordId != null ">
		        sign_patient_record_id,
	        </if>
            <if test="patientId != null">patient_id,
            </if>
            <if test="informedFileName != null">informed_file_name,
            </if>
            <if test="informedFilePath != null">informed_file_path,
            </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="signPatientRecordId != null ">
		        #{signPatientRecordId},
	        </if>
            <if test="patientId != null">#{patientId},
            </if>
            <if test="informedFileName != null">#{informedFileName},
            </if>
            <if test="informedFilePath != null">#{informedFilePath},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
        </trim>
    </insert>

    <update id="updateSignPatientInformed" parameterType="SignPatientInformed">
        update sign_patient_informed
        <trim prefix="SET" suffixOverrides=",">
	        <if test="signPatientRecordId != null ">
		        sign_patient_record_id = #{signPatientRecordId},
	        </if>
            <if test="patientId != null">patient_id =
                #{patientId},
            </if>
            <if test="informedFileName != null">informed_file_name =
                #{informedFileName},
            </if>
            <if test="informedFilePath != null">informed_file_path =
                #{informedFilePath},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSignPatientInformedById" parameterType="Long">
        delete from sign_patient_informed where id = #{id}
    </delete>

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