<?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.signpatientpackagehardware.SignPatientPackageHardwareMapper">

    <resultMap type="SignPatientPackageHardware" id="SignPatientPackageHardwareResult">
            <result property="id" column="id"/>
	        <result property="signPatientRecordId" column="sign_patient_record_id"/>
            <result property="signPatientPackageId" column="sign_patient_package_id"/>
            <result property="hardwareType" column="hardware_type"/>
            <result property="snCode" column="sn_code"/>
            <result property="hardwarePrice" column="hardware_price"/>
            <result property="hardwareStatus" column="hardware_status"/>
            <result property="hardwareManufacturer" column="hardware_manufacturer"/>
            <result property="hardwareIntroduce" column="hardware_introduce"/>
            <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="selectSignPatientPackageHardwareVo">
        select id, sign_patient_record_id, sign_patient_package_id, hardware_type, sn_code, hardware_price, hardware_status, hardware_manufacturer, hardware_introduce, create_by, create_time, update_by, update_time from sign_patient_package_hardware
    </sql>

    <select id="selectSignPatientPackageHardwareList" parameterType="SignPatientPackageHardware" resultMap="SignPatientPackageHardwareResult">
        <include refid="selectSignPatientPackageHardwareVo"/>
        <where>
	        <if test="signPatientRecordId != null ">
		        and sign_patient_record_id = #{signPatientRecordId}
	        </if>
            <if test="signPatientPackageId != null ">
                and sign_patient_package_id = #{signPatientPackageId}
            </if>
            <if test="hardwareType != null  and hardwareType != ''">
                and hardware_type = #{hardwareType}
            </if>
            <if test="snCode != null  and snCode != ''">
                and sn_code = #{snCode}
            </if>
            <if test="hardwarePrice != null ">
                and hardware_price = #{hardwarePrice}
            </if>
            <if test="hardwareStatus != null  and hardwareStatus != ''">
                and hardware_status = #{hardwareStatus}
            </if>
            <if test="hardwareManufacturer != null  and hardwareManufacturer != ''">
                and hardware_manufacturer = #{hardwareManufacturer}
            </if>
            <if test="hardwareIntroduce != null  and hardwareIntroduce != ''">
                and hardware_introduce = #{hardwareIntroduce}
            </if>
        </where>
    </select>

    <select id="selectSignPatientPackageHardwareById" parameterType="Long" resultMap="SignPatientPackageHardwareResult">
        <include refid="selectSignPatientPackageHardwareVo"/>
        where id = #{id}
    </select>

    <insert id="insertSignPatientPackageHardware" parameterType="SignPatientPackageHardware" useGeneratedKeys="true" keyProperty="id">
        insert into sign_patient_package_hardware
        <trim prefix="(" suffix=")" suffixOverrides=",">
	        <if test="signPatientRecordId != null">sign_patient_record_id,
	        </if>
            <if test="signPatientPackageId != null">sign_patient_package_id,
            </if>
            <if test="hardwareType != null">hardware_type,
            </if>
            <if test="snCode != null">sn_code,
            </if>
            <if test="hardwarePrice != null">hardware_price,
            </if>
            <if test="hardwareStatus != null">hardware_status,
            </if>
            <if test="hardwareManufacturer != null">hardware_manufacturer,
            </if>
            <if test="hardwareIntroduce != null">hardware_introduce,
            </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="signPatientPackageId != null">#{signPatientPackageId},
            </if>
            <if test="hardwareType != null">#{hardwareType},
            </if>
            <if test="snCode != null">#{snCode},
            </if>
            <if test="hardwarePrice != null">#{hardwarePrice},
            </if>
            <if test="hardwareStatus != null">#{hardwareStatus},
            </if>
            <if test="hardwareManufacturer != null">#{hardwareManufacturer},
            </if>
            <if test="hardwareIntroduce != null">#{hardwareIntroduce},
            </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="updateSignPatientPackageHardware" parameterType="SignPatientPackageHardware">
        update sign_patient_package_hardware
        <trim prefix="SET" suffixOverrides=",">
	        <if test="signPatientRecordId != null">
            sign_patient_record_id = #{signPatientRecordId},
	        </if>
            <if test="signPatientPackageId != null">sign_patient_package_id =
                #{signPatientPackageId},
            </if>
            <if test="hardwareType != null">hardware_type =
                #{hardwareType},
            </if>
            <if test="snCode != null">sn_code =
                #{snCode},
            </if>
            <if test="hardwarePrice != null">hardware_price =
                #{hardwarePrice},
            </if>
            <if test="hardwareStatus != null">hardware_status =
                #{hardwareStatus},
            </if>
            <if test="hardwareManufacturer != null">hardware_manufacturer =
                #{hardwareManufacturer},
            </if>
            <if test="hardwareIntroduce != null">hardware_introduce =
                #{hardwareIntroduce},
            </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="deleteSignPatientPackageHardwareById" parameterType="Long">
        delete from sign_patient_package_hardware where id = #{id}
    </delete>

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