<?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.ghy.order.mapper.OrderAssessLabelMapper">

    <resultMap type="OrderAssessLabel" id="OrderAssessLabelResult">
        <result property="id"    column="id"    />
        <result property="orderId"    column="order_id"    />
        <result property="labelId"    column="label_id"    />
    </resultMap>

    <sql id="selectOrderAssessLabelVo">
        select id, order_id, label_id from order_assess_label
    </sql>

    <select id="selectOrderAssessLabelList" parameterType="OrderAssessLabel" resultMap="OrderAssessLabelResult">
        <include refid="selectOrderAssessLabelVo"/>
        <where>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="labelId != null "> and label_id = #{labelId}</if>
        </where>
    </select>

    <select id="selectOrderAssessLabelById" parameterType="Long" resultMap="OrderAssessLabelResult">
        <include refid="selectOrderAssessLabelVo"/>
        where id = #{id}
    </select>

    <insert id="insertOrderAssessLabel" parameterType="OrderAssessLabel">
        insert into order_assess_label
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="orderId != null">order_id,</if>
            <if test="labelId != null">label_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="labelId != null">#{labelId},</if>
        </trim>
    </insert>

    <update id="updateOrderAssessLabel" parameterType="OrderAssessLabel">
        update order_assess_label
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="labelId != null">label_id = #{labelId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderAssessLabelById" parameterType="Long">
        delete from order_assess_label where id = #{id}
    </delete>

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

</mapper>
