<?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.productionRequest.ProProductionRequestProcessQcindexMapper">

    <resultMap type="ProProductionRequestProcessQcindex" id="ProProductionRequestProcessQcindexResult">
        <result property="productionRequestProcessQcindexId"    column="production_request_process_qcindex_id"    />
        <result property="productionRequestId"    column="production_request_id"    />
        <result property="productionRequestProcessId"    column="production_request_process_id"    />
        <result property="qcindexId"    column="qcindex_id"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectProProductionRequestProcessQcindexVo">
        select production_request_process_qcindex_id, production_request_id, production_request_process_id, qcindex_id, remark from pro_production_request_process_qcindex
    </sql>

    <select id="selectProProductionRequestProcessQcindexList" parameterType="ProProductionRequestProcessQcindex" resultMap="ProProductionRequestProcessQcindexResult">
        <include refid="selectProProductionRequestProcessQcindexVo"/>
        <where>
            <if test="productionRequestId != null ">and production_request_id =
                #{productionRequestId}
            </if>
            <if test="productionRequestProcessId != null ">and production_request_process_id =
                #{productionRequestProcessId}
            </if>
            <if test="productionRequestProcessQcindexId != null ">and production_request_process_qcindex_id = #{productionRequestProcessQcindexId}</if>
        </where>
    </select>

    <select id="selectProProductionRequestProcessQcindexByProductionRequestProcessQcindexId" parameterType="Long" resultMap="ProProductionRequestProcessQcindexResult">
        <include refid="selectProProductionRequestProcessQcindexVo"/>
        where production_request_process_qcindex_id = #{productionRequestProcessQcindexId}
    </select>

    <insert id="insertProProductionRequestProcessQcindex" parameterType="ProProductionRequestProcessQcindex" useGeneratedKeys="true" keyProperty="productionRequestProcessQcindexId">
        insert into pro_production_request_process_qcindex
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productionRequestId != null">production_request_id,</if>
            <if test="productionRequestProcessId != null">production_request_process_id,</if>
            <if test="qcindexId != null">qcindex_id,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="productionRequestId != null">#{productionRequestId},</if>
            <if test="productionRequestProcessId != null">#{productionRequestProcessId},</if>
            <if test="qcindexId != null">#{qcindexId},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateProProductionRequestProcessQcindex" parameterType="ProProductionRequestProcessQcindex">
        update pro_production_request_process_qcindex
        <trim prefix="SET" suffixOverrides=",">
            <if test="productionRequestId != null">production_request_id = #{productionRequestId},</if>
            <if test="productionRequestProcessId != null">production_request_process_id = #{productionRequestProcessId},</if>
            <if test="qcindexId != null">qcindex_id = #{qcindexId},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where production_request_process_qcindex_id = #{productionRequestProcessQcindexId}
    </update>

    <delete id="deleteProProductionRequestProcessQcindexByProductionRequestProcessQcindexId" parameterType="Long">
        delete from pro_production_request_process_qcindex where production_request_process_qcindex_id = #{productionRequestProcessQcindexId}
    </delete>

    <delete id="deleteProProductionRequestProcessQcindexByProductionRequestProcessQcindexIds" parameterType="String">
        delete from pro_production_request_process_qcindex where production_request_process_qcindex_id in
        <foreach item="productionRequestProcessQcindexId" collection="array" open="(" separator="," close=")">
            #{productionRequestProcessQcindexId}
        </foreach>
    </delete>
</mapper>
