<?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.pro.mapper.prototypeMake.ProPrototypeMakeProcessToolMapper">

    <resultMap type="ProPrototypeMakeProcessTool" id="ProPrototypeMakeProcessToolResult">
        <result property="prototypeMakeProcessToolId"    column="prototype_make_process_tool_id"    />
        <result property="prototypeMakeId"    column="prototype_make_id"    />
        <result property="prototypeMakeProcessId"    column="prototype_make_process_id"    />
        <result property="toolId"    column="tool_id"    />
        <result property="quantity"    column="quantity"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProPrototypeMakeProcessToolVo">
        select prototype_make_process_tool_id, prototype_make_id, prototype_make_process_id, tool_id, quantity, remark from pro_prototype_make_process_tool
    </sql>

    <select id="selectProPrototypeMakeProcessToolList" parameterType="ProPrototypeMakeProcessTool" resultMap="ProPrototypeMakeProcessToolResult">
        <include refid="selectProPrototypeMakeProcessToolVo"/>
        <where>
            <if test="prototypeMakeId != null ">and prototype_make_id =
                #{prototypeMakeId}
            </if>
            <if test="prototypeMakeProcessId != null ">and prototype_make_process_id =
                #{prototypeMakeProcessId}
            </if>
            <if test="prototypeMakeProcessToolId != null ">and prototype_make_process_tool_id = #{prototypeMakeProcessToolId}</if>
        </where>
    </select>

    <select id="selectProPrototypeMakeProcessToolByPrototypeMakeProcessToolId" parameterType="Long" resultMap="ProPrototypeMakeProcessToolResult">
        <include refid="selectProPrototypeMakeProcessToolVo"/>
        where prototype_make_process_tool_id = #{prototypeMakeProcessToolId}
    </select>

    <insert id="insertProPrototypeMakeProcessTool" parameterType="ProPrototypeMakeProcessTool" useGeneratedKeys="true" keyProperty="prototypeMakeProcessToolId">
        insert into pro_prototype_make_process_tool
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="prototypeMakeId != null">prototype_make_id,</if>
            <if test="prototypeMakeProcessId != null">prototype_make_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="prototypeMakeId != null">#{prototypeMakeId},</if>
            <if test="prototypeMakeProcessId != null">#{prototypeMakeProcessId},</if>
            <if test="toolId != null">#{toolId},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProPrototypeMakeProcessTool" parameterType="ProPrototypeMakeProcessTool">
        update pro_prototype_make_process_tool
        <trim prefix="SET" suffixOverrides=",">
            <if test="prototypeMakeId != null">prototype_make_id = #{prototypeMakeId},</if>
            <if test="prototypeMakeProcessId != null">prototype_make_process_id = #{prototypeMakeProcessId},</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 prototype_make_process_tool_id = #{prototypeMakeProcessToolId}
    </update>

    <delete id="deleteProPrototypeMakeProcessToolByPrototypeMakeProcessToolId" parameterType="Long">
        delete from pro_prototype_make_process_tool where prototype_make_process_tool_id = #{prototypeMakeProcessToolId}
    </delete>

    <delete id="deleteProPrototypeMakeProcessToolByPrototypeMakeProcessToolIds" parameterType="String">
        delete from pro_prototype_make_process_tool where prototype_make_process_tool_id in
        <foreach item="prototypeMakeProcessToolId" collection="array" open="(" separator="," close=")">
            #{prototypeMakeProcessToolId}
        </foreach>
    </delete>
</mapper>
