<?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.ximai.mes.dv.mapper.devBrandQuotation.DevBrandQuotationProcessToolMapper">

    <resultMap type="DevBrandQuotationProcessTool" id="DevBrandQuotationProcessToolResult">
        <result property="brandQuotationProcessToolId"    column="brand_quotation_process_tool_id"    />
        <result property="brandQuotationId"    column="brand_quotation_id"    />
        <result property="brandQuotationProcessId"    column="brand_quotation_process_id"    />
        <result property="toolId"    column="tool_id"    />
        <result property="quantity"    column="quantity"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectDevBrandQuotationProcessToolVo">
        select brand_quotation_process_tool_id, brand_quotation_id, brand_quotation_process_id, tool_id, quantity, remark from dev_brand_quotation_process_tool
    </sql>

    <select id="selectDevBrandQuotationProcessToolList" parameterType="DevBrandQuotationProcessTool" resultMap="DevBrandQuotationProcessToolResult">
        <include refid="selectDevBrandQuotationProcessToolVo"/>
        <where>
            <if test="brandQuotationId != null "> and brand_quotation_id = #{brandQuotationId}</if>
            <if test="brandQuotationProcessId != null "> and brand_quotation_process_id = #{brandQuotationProcessId}</if>
            <if test="toolId != null "> and tool_id = #{toolId}</if>
            <if test="quantity != null "> and quantity = #{quantity}</if>
        </where>
    </select>

    <select id="selectDevBrandQuotationProcessToolByBrandQuotationProcessToolId" parameterType="Long" resultMap="DevBrandQuotationProcessToolResult">
        <include refid="selectDevBrandQuotationProcessToolVo"/>
        where brand_quotation_process_tool_id = #{brandQuotationProcessToolId}
    </select>

    <insert id="insertDevBrandQuotationProcessTool" parameterType="DevBrandQuotationProcessTool" useGeneratedKeys="true" keyProperty="brandQuotationProcessToolId">
        insert into dev_brand_quotation_process_tool
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="brandQuotationId != null">brand_quotation_id,</if>
            <if test="brandQuotationProcessId != null">brand_quotation_process_id,</if>
            <if test="toolId != null">tool_id,</if>
            <if test="quantity != null">quantity,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="brandQuotationId != null">#{brandQuotationId},</if>
            <if test="brandQuotationProcessId != null">#{brandQuotationProcessId},</if>
            <if test="toolId != null">#{toolId},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateDevBrandQuotationProcessTool" parameterType="DevBrandQuotationProcessTool">
        update dev_brand_quotation_process_tool
        <trim prefix="SET" suffixOverrides=",">
            <if test="brandQuotationId != null">brand_quotation_id = #{brandQuotationId},</if>
            <if test="brandQuotationProcessId != null">brand_quotation_process_id = #{brandQuotationProcessId},</if>
            <if test="toolId != null">tool_id = #{toolId},</if>
            <if test="quantity != null">quantity = #{quantity},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where brand_quotation_process_tool_id = #{brandQuotationProcessToolId}
    </update>

    <delete id="deleteDevBrandQuotationProcessToolByBrandQuotationProcessToolId" parameterType="Long">
        delete from dev_brand_quotation_process_tool where brand_quotation_process_tool_id = #{brandQuotationProcessToolId}
    </delete>

    <delete id="deleteDevBrandQuotationProcessToolByBrandQuotationProcessToolIds" parameterType="String">
        delete from dev_brand_quotation_process_tool where brand_quotation_process_tool_id in
        <foreach item="brandQuotationProcessToolId" collection="array" open="(" separator="," close=")">
            #{brandQuotationProcessToolId}
        </foreach>
    </delete>
</mapper>
