<?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.productionSolution.ProProductionSolutionProcessQcindexMapper">


    <resultMap type="ProProductionSolutionProcessQcindex" id="ProProductionSolutionProcessQcindexResult">
        <result property="prototypeSolutionProcessQcindexId" column="prototype_solution_process_qcindex_id"/>
        <result property="prototypeSolutionId" column="prototype_solution_id"/>
        <result property="prototypeSolutionProcessId" column="prototype_solution_process_id"/>
        <result property="qcindexId" column="qcindex_id"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectProProductionSolutionProcessQcindexVo">
        select prototype_solution_process_qcindex_id,
               prototype_solution_id,
               prototype_solution_process_id,
               qcindex_id,
               remark
        from pro_production_solution_process_qcindex

    </sql>

    <select id="selectProProductionSolutionProcessQcindexList" parameterType="ProProductionSolutionProcessQcindex"
            resultMap="ProProductionSolutionProcessQcindexResult">
        <include refid="selectProProductionSolutionProcessQcindexVo"/>
        <where>
            <if test="prototypeSolutionId != null ">and prototype_solution_id = #{prototypeSolutionId}</if>
            <if test="prototypeSolutionProcessId != null ">and prototype_solution_process_id =
                #{prototypeSolutionProcessId}
            </if>
            <if test="qcindexId != null ">and qcindex_id = #{qcindexId}</if>
        </where>
    </select>

    <select id="selectProProductionSolutionProcessQcindexByPrototypeSolutionProcessId" parameterType="Long"
            resultMap="ProProductionSolutionProcessQcindexResult">
        <include refid="selectProProductionSolutionProcessQcindexVo"/>
        where prototype_solution_process_id = #{prototypeSolutionProcessId}
    </select>

    <select id="selectProProductionSolutionProcessQcindexByPrototypeSolutionProcessQcindexId" parameterType="Long"
            resultMap="ProProductionSolutionProcessQcindexResult">
        <include refid="selectProProductionSolutionProcessQcindexVo"/>
        where prototype_solution_process_qcindex_id = #{prototypeSolutionProcessQcindexId}
    </select>

    <insert id="insertProProductionSolutionProcessQcindex" parameterType="ProProductionSolutionProcessQcindex"
            useGeneratedKeys="true" keyProperty="prototypeSolutionProcessQcindexId">
        insert into pro_production_solution_process_qcindex
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="prototypeSolutionId != null">prototype_solution_id,</if>
            <if test="prototypeSolutionProcessId != null">prototype_solution_process_id,</if>
            <if test="qcindexId != null">qcindex_id,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="prototypeSolutionId != null">#{prototypeSolutionId},</if>
            <if test="prototypeSolutionProcessId != null">#{prototypeSolutionProcessId},</if>
            <if test="qcindexId != null">#{qcindexId},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateProProductionSolutionProcessQcindex" parameterType="ProProductionSolutionProcessQcindex">
        update pro_production_solution_process_qcindex
        <trim prefix="SET" suffixOverrides=",">
            <if test="prototypeSolutionId != null">prototype_solution_id = #{prototypeSolutionId},</if>
            <if test="prototypeSolutionProcessId != null">prototype_solution_process_id =
                #{prototypeSolutionProcessId},
            </if>
            <if test="qcindexId != null">qcindex_id = #{qcindexId},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where prototype_solution_process_qcindex_id = #{prototypeSolutionProcessQcindexId}
    </update>

    <delete id="deleteProProductionSolutionProcessQcindexByPrototypeSolutionProcessQcindexId" parameterType="Long">
        delete
        from pro_production_solution_process_qcindex
        where prototype_solution_process_qcindex_id = #{prototypeSolutionProcessQcindexId}
    </delete>

    <delete id="deleteProProductionSolutionProcessQcindexByPrototypeSolutionProcessQcindexIds" parameterType="String">
        delete from pro_production_solution_process_qcindex where prototype_solution_process_qcindex_id in
        <foreach item="prototypeSolutionProcessQcindexId" collection="array" open="(" separator="," close=")">
            #{prototypeSolutionProcessQcindexId}
        </foreach>
    </delete>
</mapper>
