<?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.djhk.uav.uav.mapper.ThreedModelInfoMapper">
    
    <resultMap type="com.djhk.uav.uav.domain.ThreedModelInfo" id="ThreedModelInfoResult">
        <result property="modelId"    column="model_id"    />
        <result property="modelName"    column="model_name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="modelFile"    column="model_file"    />
        <result property="dealSts"    column="deal_sts"    />
        <result property="begTime"    column="beg_time"    />
        <result property="endTime"    column="end_time"    />
        <result property="modelAlt"    column="model_alt"    />
        <result property="modelType"    column="model_type"    />
        <result property="modelSts"    column="model_sts"    />
        <result property="path"    column="path"    />
        <result property="modelLock"    column="model_lock"    />
    </resultMap>

    <sql id="selectThreedModelInfoVo">
        select model_id, model_name, create_by, create_time, update_by, update_time, model_file, deal_sts, beg_time, end_time, model_alt, model_type, model_sts, path, model_lock from threed_model_info
    </sql>

    <select id="selectThreedModelInfoList" parameterType="com.djhk.uav.uav.domain.ThreedModelInfo" resultMap="ThreedModelInfoResult">
        <include refid="selectThreedModelInfoVo"/>
        <where>  
            <if test="modelName != null  and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
            <if test="modelFile != null "> and model_file = #{modelFile}</if>
            <if test="dealSts != null  and dealSts != ''"> and deal_sts = #{dealSts}</if>
            <if test="begTime != null "> and beg_time = #{begTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
            <if test="modelAlt != null "> and model_alt = #{modelAlt}</if>
            <if test="modelType != null  and modelType != ''"> and model_type = #{modelType}</if>
            <if test="modelSts != null  and modelSts != ''"> and model_sts = #{modelSts}</if>
            <if test="path != null  and path != ''"> and path = #{path}</if>
            <if test="modelLock != null  and modelLock != ''"> and model_lock = #{modelLock}</if>
<!--            <if test="orgIds != null and orgIds.size() > 0">-->
<!--                and dept_id in-->
<!--                <foreach collection="orgIds" item="item" open="(" separator="," close=")">-->
<!--                    #{item}-->
<!--                </foreach>-->
<!--            </if>-->
        </where>
        ORDER BY create_time DESC
    </select>
    
    <select id="selectThreedModelInfoByModelId" parameterType="Long" resultMap="ThreedModelInfoResult">
        <include refid="selectThreedModelInfoVo"/>
        where model_id = #{modelId}
    </select>
    <select id="selectThreedModelInfoAllList" resultType="com.djhk.uav.uav.domain.ThreedModelInfo">
        <include refid="selectThreedModelInfoVo"/>
        where model_sts = '1' and deal_sts = '3'
    </select>


    <select id="selectThreedModelInfoLists" resultType="com.djhk.uav.uav.domain.ThreedModelInfo">
        <include refid="selectThreedModelInfoVo"/>
        where model_sts = '1' and deal_sts = '3'
        and dept_id = #{deptId}
    </select>

    <insert id="insertThreedModelInfo" parameterType="com.djhk.uav.uav.domain.ThreedModelInfo" useGeneratedKeys="true" keyProperty="modelId">
        insert into threed_model_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="modelName != null">model_name,</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>
            <if test="modelFile != null">model_file,</if>
            <if test="dealSts != null">deal_sts,</if>
            <if test="begTime != null">beg_time,</if>
            <if test="endTime != null">end_time,</if>
            <if test="modelAlt != null">model_alt,</if>
            <if test="modelType != null">model_type,</if>
            <if test="modelSts != null">model_sts,</if>
            <if test="path != null">path,</if>
            <if test="modelLock != null">model_lock,</if>
            <if test="deptId != null">dept_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="modelName != null">#{modelName},</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>
            <if test="modelFile != null">#{modelFile},</if>
            <if test="dealSts != null">#{dealSts},</if>
            <if test="begTime != null">#{begTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="modelAlt != null">#{modelAlt},</if>
            <if test="modelType != null">#{modelType},</if>
            <if test="modelSts != null">#{modelSts},</if>
            <if test="path != null">#{path},</if>
            <if test="modelLock != null">#{modelLock},</if>
            <if test="deptId != null">#{deptId},</if>
         </trim>
    </insert>

    <update id="updateThreedModelInfo" parameterType="com.djhk.uav.uav.domain.ThreedModelInfo">
        update threed_model_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="modelName != null">model_name = #{modelName},</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>
            <if test="modelFile != null">model_file = #{modelFile},</if>
            <if test="dealSts != null">deal_sts = #{dealSts},</if>
            <if test="begTime != null">beg_time = #{begTime},</if>
            <if test="endTime != null">end_time = #{endTime},</if>
            <if test="modelAlt != null">model_alt = #{modelAlt},</if>
            <if test="modelType != null">model_type = #{modelType},</if>
            <if test="modelSts != null">model_sts = #{modelSts},</if>
            <if test="path != null">path = #{path},</if>
            <if test="modelLock != null">model_lock = #{modelLock},</if>
        </trim>
        where model_id = #{modelId}
    </update>

    <delete id="deleteThreedModelInfoByModelId" parameterType="Long">
        delete from threed_model_info where model_id = #{modelId}
    </delete>

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