<?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.ics.admin.mapper.meeting.DetailEquipmentMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.DetailEquipment" id="DetailEquipmentResult">
        <result property="id"    column="id"    />
        <result property="equipmentId"    column="equipment_id"    />
        <result property="buildingDetailId"    column="building_detail_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectDetailEquipmentVo">
        SELECT id, equipment_id, building_detail_id, create_time, delete_flag, create_by FROM tb_detail_equipment
    </sql>

    <select id="selectDetailEquipmentList" parameterType="DetailEquipment" resultMap="DetailEquipmentResult">
        <include refid="selectDetailEquipmentVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectDetailEquipmentById" parameterType="Long" resultMap="DetailEquipmentResult">
        <include refid="selectDetailEquipmentVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertDetailEquipment" parameterType="DetailEquipment" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_detail_equipment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="equipmentId != null ">equipment_id,</if>
            <if test="buildingDetailId != null ">building_detail_id,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="deleteFlag != null  and deleteFlag != ''">delete_flag,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="equipmentId != null ">#{equipmentId},</if>
            <if test="buildingDetailId != null ">#{buildingDetailId},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="deleteFlag != null  and deleteFlag != ''">#{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateDetailEquipment" parameterType="DetailEquipment">
        UPDATE tb_detail_equipment
        <trim prefix="SET" suffixOverrides=",">
            <if test="equipmentId != null ">equipment_id = #{equipmentId},</if>
            <if test="buildingDetailId != null ">building_detail_id = #{buildingDetailId},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="deleteFlag != null  and deleteFlag != ''">delete_flag = #{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteDetailEquipmentById" parameterType="Long">
        DELETE FROM tb_detail_equipment WHERE id = #{id}
    </delete>

    <delete id="deleteDetailEquipmentByIds" parameterType="String">
        DELETE FROM tb_detail_equipment where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>