<?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.inspect.metadata.eqpbook.mapper.BasedataEqpBookModelMapper">

    <resultMap type="BasedataEqpBookModel" id="BasedataEqpBookModelResult">
        <result property="eqpBookModelId" column="eqp_book_model_id"/>
        <result property="eqpBookId" column="eqp_book_id"/>
        <result property="modelType" column="model_type"/>
        <result property="positionX" column="position_x"/>
        <result property="positionY" column="position_y"/>
        <result property="positionZ" column="position_z"/>
        <result property="deviceLength" column="device_length"/>
        <result property="deviceWidth" column="device_width"/>
        <result property="deviceHigh" column="device_high"/>
        <result property="delFlag" column="del_flag"/>
        <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="selectBasedataEqpBookModelVo">
        select eqp_book_model_id,
               eqp_book_id,
               model_type,
               position_x,
               position_y,
               position_z,
               device_length,
               device_width,
               device_high,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time
        from basedata_eqpbook_model
    </sql>

    <select id="selectBasedataEqpBookModelList" parameterType="BasedataEqpBookModel"
            resultMap="BasedataEqpBookModelResult">
        <include refid="selectBasedataEqpBookModelVo"/>
        <where>
            <if test="eqpBookId != null ">and eqp_book_id = #{eqpBookId}</if>
            <if test="modelType != null  and modelType != ''">and model_type = #{modelType}</if>
            <if test="positionX != null  and positionX != ''">and position_x = #{positionX}</if>
            <if test="positionY != null  and positionY != ''">and position_y = #{positionY}</if>
            <if test="positionZ != null  and positionZ != ''">and position_z = #{positionZ}</if>
            <if test="deviceLength != null  and deviceLength != ''">and device_length = #{deviceLength}</if>
            <if test="deviceWidth != null  and deviceWidth != ''">and device_width = #{deviceWidth}</if>
            <if test="deviceHigh != null  and deviceHigh != ''">and device_high = #{deviceHigh}</if>
        </where>
    </select>

    <select id="selectBasedataEqpBookModelByEqpBookModelId" parameterType="String"
            resultMap="BasedataEqpBookModelResult">
        <include refid="selectBasedataEqpBookModelVo"/>
        where eqp_book_model_id = #{eqpBookModelId}
    </select>

    <insert id="insertBasedataEqpBookModel" parameterType="BasedataEqpBookModel" useGeneratedKeys="true"
            keyProperty="eqpBookModelId">
        insert into basedata_eqpbook_model
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eqpBookId != null">eqp_book_id,</if>
            <if test="modelType != null">model_type,</if>
            <if test="positionX != null">position_x,</if>
            <if test="positionY != null">position_y,</if>
            <if test="positionZ != null">position_z,</if>
            <if test="deviceLength != null">device_length,</if>
            <if test="deviceWidth != null">device_width,</if>
            <if test="deviceHigh != null">device_high,</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="eqpBookId != null">#{eqpBookId},</if>
            <if test="modelType != null">#{modelType},</if>
            <if test="positionX != null">#{positionX},</if>
            <if test="positionY != null">#{positionY},</if>
            <if test="positionZ != null">#{positionZ},</if>
            <if test="deviceLength != null">#{deviceLength},</if>
            <if test="deviceWidth != null">#{deviceWidth},</if>
            <if test="deviceHigh != null">#{deviceHigh},</if>
            <if test="delFlag != null">#{delFlag},</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="updateBasedataEqpBookModel" parameterType="BasedataEqpBookModel">
        update basedata_eqpbook_model
        <trim prefix="SET" suffixOverrides=",">
            <if test="eqpBookId != null">eqp_book_id = #{eqpBookId},</if>
            <if test="modelType != null">model_type = #{modelType},</if>
            <if test="positionX != null">position_x = #{positionX},</if>
            <if test="positionY != null">position_y = #{positionY},</if>
            <if test="positionZ != null">position_z = #{positionZ},</if>
            <if test="deviceLength != null">device_length = #{deviceLength},</if>
            <if test="deviceWidth != null">device_width = #{deviceWidth},</if>
            <if test="deviceHigh != null">device_high = #{deviceHigh},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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 eqp_book_model_id = #{eqpBookModelId}
    </update>

    <delete id="deleteBasedataEqpBookModelByEqpBookModelId" parameterType="String">
        delete
        from basedata_eqpbook_model
        where eqp_book_model_id = #{eqpBookModelId}
    </delete>

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