<?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.ruoyi.project.business.mapper.quotation.TqSpecificationDetailMapper">
    
    <resultMap type="TqSpecificationDetail" id="TqSpecificationDetailResult">
        <result property="id"    column="id"    />
        <result property="specificationId"    column="specification_id"    />
        <result property="paraCode"    column="para_code"    />
        <result property="paraValue"    column="para_value"    />
        <result property="parabarDetailId"    column="parabar_detail_id"    />
        <result property="parabarId"    column="parabar_id"    />
        <result property="paraCategory"    column="para_category"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTqSpecificationDetailVo">
        select id, specification_id, para_code, para_value, parabar_detail_id, parabar_id, para_category, del_flag, create_time, create_by, update_time, update_by, remark from tq_specification_detail
    </sql>

    <select id="selectTqSpecificationDetailList" parameterType="TqSpecificationDetail" resultMap="TqSpecificationDetailResult">
        <include refid="selectTqSpecificationDetailVo"/>
        <where>  
            <if test="specificationId != null "> and specification_id = #{specificationId}</if>
            <if test="paraCode != null  and paraCode != ''"> and para_code = #{paraCode}</if>
            <if test="paraValue != null  and paraValue != ''"> and para_value = #{paraValue}</if>
            <if test="parabarDetailId != null "> and parabar_detail_id = #{parabarDetailId}</if>
            <if test="parabarId != null "> and parabar_id = #{parabarId}</if>
            <if test="paraCategory != null  and paraCategory != ''"> and para_category = #{paraCategory}</if>
        </where>
    </select>
    
    <select id="selectTqSpecificationDetailById" parameterType="Long" resultMap="TqSpecificationDetailResult">
        <include refid="selectTqSpecificationDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTqSpecificationDetail" parameterType="TqSpecificationDetail" useGeneratedKeys="true" keyProperty="id">
        insert into tq_specification_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="specificationId != null">specification_id,</if>
            <if test="paraCode != null">para_code,</if>
            <if test="paraValue != null">para_value,</if>
            <if test="parabarDetailId != null">parabar_detail_id,</if>
            <if test="parabarId != null">parabar_id,</if>
            <if test="paraCategory != null">para_category,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="specificationId != null">#{specificationId},</if>
            <if test="paraCode != null">#{paraCode},</if>
            <if test="paraValue != null">#{paraValue},</if>
            <if test="parabarDetailId != null">#{parabarDetailId},</if>
            <if test="parabarId != null">#{parabarId},</if>
            <if test="paraCategory != null">#{paraCategory},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTqSpecificationDetail" parameterType="TqSpecificationDetail">
        update tq_specification_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="specificationId != null">specification_id = #{specificationId},</if>
            <if test="paraCode != null">para_code = #{paraCode},</if>
            <if test="paraValue != null">para_value = #{paraValue},</if>
            <if test="parabarDetailId != null">parabar_detail_id = #{parabarDetailId},</if>
            <if test="parabarId != null">parabar_id = #{parabarId},</if>
            <if test="paraCategory != null">para_category = #{paraCategory},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTqSpecificationDetailById" parameterType="Long">
        delete from tq_specification_detail where id = #{id}
    </delete>

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