<?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.soss.system.mapper.OrderOperationLogMapper">
    
    <resultMap type="OrderOperationLog" id="OrderOperationLogResult">
        <result property="id"    column="id"    />
        <result property="status"    column="status"    />
        <result property="operation"    column="operation"    />
        <result property="createAt"    column="create_at"    />
        <result property="operationUser"    column="operation_user"    />
        <result property="content"    column="content"    />
        <result property="orderId"    column="order_id"    />
    </resultMap>

    <sql id="selectOrderOperationLogVo">
        select id, status, operation, create_at, operation_user, content, order_id from order_operation_log
    </sql>

    <select id="selectOrderOperationLogList" parameterType="OrderOperationLog" resultMap="OrderOperationLogResult">
        <include refid="selectOrderOperationLogVo"/>
        <where>  
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="operation != null  and operation != ''"> and operation = #{operation}</if>
            <if test="createAt != null "> and create_at = #{createAt}</if>
            <if test="operationUser != null  and operationUser != ''"> and operation_user = #{operationUser}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
        </where>
    </select>
    
    <select id="selectOrderOperationLogById" parameterType="String" resultMap="OrderOperationLogResult">
        <include refid="selectOrderOperationLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOrderOperationLog" parameterType="OrderOperationLog" useGeneratedKeys="true" keyProperty="id">
        insert into order_operation_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="status != null and status != ''">status,</if>
            <if test="operation != null and operation != ''">operation,</if>
            <if test="createAt != null">create_at,</if>
            <if test="operationUser != null and operationUser != ''">operation_user,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="orderId != null">order_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="status != null and status != ''">#{status},</if>
            <if test="operation != null and operation != ''">#{operation},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="operationUser != null and operationUser != ''">#{operationUser},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="orderId != null">#{orderId},</if>
         </trim>
    </insert>

    <update id="updateOrderOperationLog" parameterType="OrderOperationLog">
        update order_operation_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null and status != ''">status = #{status},</if>
            <if test="operation != null and operation != ''">operation = #{operation},</if>
            <if test="operationUser != null and operationUser != ''">operation_user = #{operationUser},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOrderOperationLogById" parameterType="String">
        delete from order_operation_log where id = #{id}
    </delete>

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