<?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.frequency.orderextensionrecord.mapper.OrderExtensionRecordMapper">
    
    <resultMap type="com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord" id="OrderExtensionRecordResult">
        <result property="id"    column="id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="orderId"    column="order_id"    />
        <result property="originTime"    column="origin_time"    />
        <result property="changeTime"    column="change_time"    />
        <result property="userId"    column="user_id"    />
        <result property="userType"    column="user_type"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectOrderExtensionRecordVo">
        select id, create_by, create_time, update_by, update_time, del_flag, order_id, origin_time, change_time, user_id, user_type, status, remark from t_order_extension_record
    </sql>

    <select id="selectOrderExtensionRecordList" parameterType="com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord" resultMap="OrderExtensionRecordResult">
        <include refid="selectOrderExtensionRecordVo"/>
        <where>  
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="originTime != null "> and origin_time = #{originTime}</if>
            <if test="changeTime != null "> and change_time = #{changeTime}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="userType != null "> and user_type = #{userType}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
       order by create_time desc
    </select>
    
    <select id="selectOrderExtensionRecordById" parameterType="Long" resultMap="OrderExtensionRecordResult">
        <include refid="selectOrderExtensionRecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOrderExtensionRecord" parameterType="com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord">
        insert into t_order_extension_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="orderId != null">order_id,</if>
            <if test="originTime != null">origin_time,</if>
            <if test="changeTime != null">change_time,</if>
            <if test="userId != null">user_id,</if>
            <if test="userType != null">user_type,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="originTime != null">#{originTime},</if>
            <if test="changeTime != null">#{changeTime},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userType != null">#{userType},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateOrderExtensionRecord" parameterType="com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord">
        update t_order_extension_record
        <trim prefix="SET" suffixOverrides=",">
    <if test="createBy != null">create_by = #{createBy},</if>
    <if test="createTime != null">create_time = #{createTime},</if>
    <if test="updateBy != null">update_by = #{updateBy},</if>
    <if test="updateTime != null">update_time = #{updateTime},</if>
    <if test="delFlag != null">del_flag = #{delFlag},</if>
    <if test="orderId != null">order_id = #{orderId},</if>
    <if test="originTime != null">origin_time = #{originTime},</if>
    <if test="changeTime != null">change_time = #{changeTime},</if>
    <if test="userId != null">user_id = #{userId},</if>
    <if test="userType != null">user_type = #{userType},</if>
    <if test="status != null">status = #{status},</if>
    <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>