<?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.system.mapper.PosOrderLogMapper">

    <resultMap type="PosOrderLog" id="PosOrderLogResult">
        <id     property="id"            column="id"             />
        <result property="ddId"          column="dd_id"          />
        <result property="operatorType"  column="operator_type"  />
        <result property="operatorId"    column="operator_id"    />
        <result property="operatorName"  column="operator_name"  />
        <result property="content"       column="content"        />
        <result property="logTime"       column="create_time"    />
    </resultMap>

    <sql id="selectOrderLogVo">
        select id, dd_id, operator_type, operator_id, operator_name, content, create_time
        from pos_order_log
    </sql>

    <insert id="insertOrderLog" parameterType="PosOrderLog">
        insert into pos_order_log(dd_id, operator_type, operator_id, operator_name, content, create_time)
        values (#{ddId}, #{operatorType}, #{operatorId}, #{operatorName}, #{content}, sysdate())
    </insert>

    <select id="selectOrderLogList" parameterType="PosOrderLog" resultMap="PosOrderLogResult">
        <include refid="selectOrderLogVo"/>
        <where>
            <if test="ddId != null and ddId != ''">
                AND dd_id like concat('%', #{ddId}, '%')
            </if>
            <if test="operatorId != null">
                AND operator_id = #{operatorId}
            </if>
            <if test="operatorName != null and operatorName != ''">
                AND operator_name like concat('%', #{operatorName}, '%')
            </if>
            <if test="operatorType != null">
                AND operator_type = #{operatorType}
            </if>
            <if test="params.beginTime != null and params.beginTime != ''">
                AND create_time &gt;= #{params.beginTime}
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                AND create_time &lt;= #{params.endTime}
            </if>
        </where>
        order by id desc
    </select>

    <select id="selectOrderLogById" parameterType="Long" resultMap="PosOrderLogResult">
        <include refid="selectOrderLogVo"/>
        where id = #{id}
    </select>

</mapper>