<?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.meas.system.mapper.MeasEngineModelMapper">

    <resultMap type="MeasEngineModel" id="MeasEngineModelResult">
        <result property="id" column="id"/>
        <result property="model" column="model"/>
        <result property="geometryFiles" column="geometry_files"/>
        <result property="geometryImage" column="geometry_image"/>
        <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="selectMeasEngineModelVo">
        select id, model, geometry_files, geometry_image, create_by, create_time, update_by, update_time from
        meas_engine_model
    </sql>

    <select id="selectMeasEngineModelList" parameterType="MeasEngineModel" resultMap="MeasEngineModelResult">
        <include refid="selectMeasEngineModelVo"/>
        <where>
            <if test="model != null  and model != ''">and model = #{model}</if>
            <if test="geometryFiles != null  and geometryFiles != ''">and geometry_files = #{geometryFiles}</if>
            <if test="geometryImage != null  and geometryImage != ''">and geometry_image = #{geometryImage}</if>
        </where>
    </select>

    <select id="selectMeasEngineModelById" parameterType="Long" resultMap="MeasEngineModelResult">
        <include refid="selectMeasEngineModelVo"/>
        where id = #{id}
    </select>

    <insert id="insertMeasEngineModel" parameterType="MeasEngineModel">
        insert into meas_engine_model
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="model != null and model != ''">model,</if>
            <if test="geometryFiles != null">geometry_files,</if>
            <if test="geometryImage != null">geometry_image,</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},</if>
            <if test="model != null and model != ''">#{model},</if>
            <if test="geometryFiles != null">#{geometryFiles},</if>
            <if test="geometryImage != null">#{geometryImage},</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="updateMeasEngineModel" parameterType="MeasEngineModel">
        update meas_engine_model
        <trim prefix="SET" suffixOverrides=",">
            <if test="model != null and model != ''">model = #{model},</if>
            <if test="geometryFiles != null">geometry_files = #{geometryFiles},</if>
            <if test="geometryImage != null">geometry_image = #{geometryImage},</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="deleteMeasEngineModelById" parameterType="Long">
        delete from meas_engine_model where id = #{id}
    </delete>

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

    <select id="getOption" resultType="Map">
        select id,model from meas_engine_model order by id asc
    </select>
</mapper>