<?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.fidms.web.mapper.Model3dMapper">
    
    <resultMap type="Model3d" id="Model3dResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="model3dFile"    column="model_3d_file"    />
        <result property="model3dFilePath"    column="model_3d_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="selectModel3dVo">
        select id, name, model_3d_file, model_3d_file_path, create_by, create_time, update_by, update_time from bz_model_3d_t
    </sql>

    <select id="selectModel3dList" parameterType="Model3d" resultMap="Model3dResult">
        <include refid="selectModel3dVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="model3dFile != null  and model3dFile != ''"> and model_3d_file = #{model3dFile}</if>
            <if test="model3dFilePath != null  and model3dFilePath != ''"> and model_3d_file_path = #{model3dFilePath}</if>
        </where>
    </select>
    
    <select id="selectModel3dById" parameterType="Long" resultMap="Model3dResult">
        <include refid="selectModel3dVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertModel3d" parameterType="Model3d" useGeneratedKeys="true" keyProperty="id">
        insert into bz_model_3d_t
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="model3dFile != null and model3dFile != ''">model_3d_file,</if>
            <if test="model3dFilePath != null and model3dFilePath != ''">model_3d_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="name != null and name != ''">#{name},</if>
            <if test="model3dFile != null and model3dFile != ''">#{model3dFile},</if>
            <if test="model3dFilePath != null and model3dFilePath != ''">#{model3dFilePath},</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="updateModel3d" parameterType="Model3d">
        update bz_model_3d_t
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="model3dFile != null and model3dFile != ''">model_3d_file = #{model3dFile},</if>
            <if test="model3dFilePath != null and model3dFilePath != ''">model_3d_file_path = #{model3dFilePath},</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="deleteModel3dById" parameterType="Long">
        delete from bz_model_3d_t where id = #{id}
    </delete>

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

    <select id="getOption" resultType="Map">
        select id, name from bz_model_3d_t order by id desc
    </select>
</mapper>