<?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.productionMake.ProProductionMakeProcessToolMapper">

    <resultMap type="ProProductionMakeProcessTool" id="ProProductionMakeProcessToolResult">
        <result property="productionMakeProcessToolId"    column="production_make_process_tool_id"    />
        <result property="productionMakeId"    column="production_make_id"    />
        <result property="productionMakeProcessId"    column="production_make_process_id"    />
        <result property="toolId"    column="tool_id"    />
        <result property="quantity"    column="quantity"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProProductionMakeProcessToolVo">
        select production_make_process_tool_id, production_make_id, production_make_process_id, tool_id, quantity, remark from pro_production_make_process_tool
    </sql>

    <select id="selectProProductionMakeProcessToolList" parameterType="ProProductionMakeProcessTool" resultMap="ProProductionMakeProcessToolResult">
        <include refid="selectProProductionMakeProcessToolVo"/>
        <where>
            <if test="productionMakeId != null ">and production_make_id =
                #{productionMakeId}
            </if>
            <if test="productionMakeProcessId != null ">and production_make_process_id =
                #{productionMakeProcessId}
            </if>
            <if test="productionMakeProcessToolId != null ">and production_make_process_tool_id = #{productionMakeProcessToolId}</if>
        </where>
    </select>

    <select id="selectProProductionMakeProcessToolByProductionMakeProcessToolId" parameterType="Long" resultMap="ProProductionMakeProcessToolResult">
        <include refid="selectProProductionMakeProcessToolVo"/>
        where production_make_process_tool_id = #{productionMakeProcessToolId}
    </select>

    <insert id="insertProProductionMakeProcessTool" parameterType="ProProductionMakeProcessTool" useGeneratedKeys="true" keyProperty="productionMakeProcessToolId">
        insert into pro_production_make_process_tool
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productionMakeId != null">production_make_id,</if>
            <if test="productionMakeProcessId != null">production_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="productionMakeId != null">#{productionMakeId},</if>
            <if test="productionMakeProcessId != null">#{productionMakeProcessId},</if>
            <if test="toolId != null">#{toolId},</if>
            <if test="quantity != null">#{quantity},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProProductionMakeProcessTool" parameterType="ProProductionMakeProcessTool">
        update pro_production_make_process_tool
        <trim prefix="SET" suffixOverrides=",">
            <if test="productionMakeId != null">production_make_id = #{productionMakeId},</if>
            <if test="productionMakeProcessId != null">production_make_process_id = #{productionMakeProcessId},</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 production_make_process_tool_id = #{productionMakeProcessToolId}
    </update>

    <delete id="deleteProProductionMakeProcessToolByProductionMakeProcessToolId" parameterType="Long">
        delete from pro_production_make_process_tool where production_make_process_tool_id = #{productionMakeProcessToolId}
    </delete>

    <delete id="deleteProProductionMakeProcessToolByProductionMakeProcessToolIds" parameterType="String">
        delete from pro_production_make_process_tool where production_make_process_tool_id in
        <foreach item="productionMakeProcessToolId" collection="array" open="(" separator="," close=")">
            #{productionMakeProcessToolId}
        </foreach>
    </delete>
</mapper>
