<?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.yiqi.order.mapper.OrderClothStatusRecordMapper">

    <resultMap type="OrderClothStatusRecord" id="OrderClothStatusRecordResult">
        <result property="id" column="id"/>
        <result property="orderId" column="order_id"/>
        <result property="orderNo" column="order_no"/>
        <result property="orderStatus" column="order_status"/>
        <result property="orderStatusName" column="order_status_name"/>
        <result property="pics" column="pics"/>
        <result property="deliveryAppUserId" column="delivery_app_user_id"/>
    </resultMap>

    <sql id="selectOrderClothStatusRecordVo">
        select id, order_id, order_no, order_status, order_status_name, pics, delivery_app_user_id
        from order_cloth_status_record
    </sql>

    <select id="selectOrderClothStatusRecordList" parameterType="OrderClothStatusRecord" resultMap="OrderClothStatusRecordResult">
        <include refid="selectOrderClothStatusRecordVo"/>
        <where>
            <if test="orderId != null ">
                and order_id = #{orderId}
            </if>
            <if test="orderNo != null  and orderNo != ''">
                and order_no = #{orderNo}
            </if>
            <if test="orderStatus != null  and orderStatus != ''">
                and order_status = #{orderStatus}
            </if>
            <if test="orderStatusName != null  and orderStatusName != ''">
                and order_status_name like concat('%', #{orderStatusName}, '%')
            </if>
            <if test="pics != null  and pics != ''">
                and pics = #{pics}
            </if>
            <if test="deliveryAppUserId != null ">
                and delivery_app_user_id = #{deliveryAppUserId}
            </if>
        </where>
    </select>

    <select id="selectOrderClothStatusRecordById" parameterType="Long"
            resultMap="OrderClothStatusRecordResult">
        <include refid="selectOrderClothStatusRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertOrderClothStatusRecord" parameterType="OrderClothStatusRecord" useGeneratedKeys="true"
            keyProperty="id">
        insert into order_cloth_status_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,
            </if>
            <if test="orderNo != null">order_no,
            </if>
            <if test="orderStatus != null">order_status,
            </if>
            <if test="orderStatusName != null">order_status_name,
            </if>
            <if test="pics != null">pics,
            </if>
            <if test="deliveryAppUserId != null">delivery_app_user_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},
            </if>
            <if test="orderNo != null">#{orderNo},
            </if>
            <if test="orderStatus != null">#{orderStatus},
            </if>
            <if test="orderStatusName != null">#{orderStatusName},
            </if>
            <if test="pics != null">#{pics},
            </if>
            <if test="deliveryAppUserId != null">#{deliveryAppUserId},
            </if>
        </trim>
    </insert>

    <update id="updateOrderClothStatusRecord" parameterType="OrderClothStatusRecord">
        update order_cloth_status_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id =
                #{orderId},
            </if>
            <if test="orderNo != null">order_no =
                #{orderNo},
            </if>
            <if test="orderStatus != null">order_status =
                #{orderStatus},
            </if>
            <if test="orderStatusName != null">order_status_name =
                #{orderStatusName},
            </if>
            <if test="pics != null">pics =
                #{pics},
            </if>
            <if test="deliveryAppUserId != null">delivery_app_user_id =
                #{deliveryAppUserId},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderClothStatusRecordById" parameterType="Long">
            delete from order_cloth_status_record where id = #{id}
        </delete>

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



</mapper>