<?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.prototypeRequest.ProPrototypeRequestProcessToolMapper">

    <resultMap type="ProPrototypeRequestProcessTool" id="ProPrototypeRequestProcessToolResult">
        <result property="prototypeRequestProcessToolId"    column="prototype_request_process_tool_id"    />
        <result property="prototypeRequestId"    column="prototype_request_id"    />
        <result property="prototypeRequestProcessId"    column="prototype_request_process_id"    />
        <result property="toolId"    column="tool_id"    />
        <result property="quantity"    column="quantity"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProPrototypeRequestProcessToolVo">
        select prototype_request_process_tool_id, prototype_request_id, prototype_request_process_id, tool_id, quantity, remark from pro_prototype_request_process_tool
    </sql>

    <select id="selectProPrototypeRequestProcessToolList" parameterType="ProPrototypeRequestProcessTool" resultMap="ProPrototypeRequestProcessToolResult">
        <include refid="selectProPrototypeRequestProcessToolVo"/>
        <where>
            <if test="prototypeRequestProcessId != null ">and prototype_request_process_id =
                #{prototypeRequestProcessId}
            </if>
            <if test="prototypeRequestProcessToolId != null ">and prototype_request_process_tool_id = #{prototypeRequestProcessToolId}</if>
        </where>
    </select>

    <select id="selectProPrototypeRequestProcessToolByPrototypeRequestProcessToolId" parameterType="Long" resultMap="ProPrototypeRequestProcessToolResult">
        <include refid="selectProPrototypeRequestProcessToolVo"/>
        where prototype_request_process_tool_id = #{prototypeRequestProcessToolId}
    </select>

    <insert id="insertProPrototypeRequestProcessTool" parameterType="ProPrototypeRequestProcessTool" useGeneratedKeys="true" keyProperty="prototypeRequestProcessToolId">
        insert into pro_prototype_request_process_tool
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="prototypeRequestId != null">prototype_request_id,</if>
            <if test="prototypeRequestProcessId != null">prototype_request_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="prototypeRequestId != null">#{prototypeRequestId},</if>
            <if test="prototypeRequestProcessId != null">#{prototypeRequestProcessId},</if>
            <if test="toolId != null">#{toolId},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProPrototypeRequestProcessTool" parameterType="ProPrototypeRequestProcessTool">
        update pro_prototype_request_process_tool
        <trim prefix="SET" suffixOverrides=",">
            <if test="prototypeRequestId != null">prototype_request_id = #{prototypeRequestId},</if>
            <if test="prototypeRequestProcessId != null">prototype_request_process_id = #{prototypeRequestProcessId},</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_request_process_tool_id = #{prototypeRequestProcessToolId}
    </update>

    <delete id="deleteProPrototypeRequestProcessToolByPrototypeRequestProcessToolId" parameterType="Long">
        delete from pro_prototype_request_process_tool where prototype_request_process_tool_id = #{prototypeRequestProcessToolId}
    </delete>

    <delete id="deleteProPrototypeRequestProcessToolByPrototypeRequestProcessToolIds" parameterType="String">
        delete from pro_prototype_request_process_tool where prototype_request_process_tool_id in
        <foreach item="prototypeRequestProcessToolId" collection="array" open="(" separator="," close=")">
            #{prototypeRequestProcessToolId}
        </foreach>
    </delete>
</mapper>
