<?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.zm.order.tool.server.old.routing.OldHintOrderOperationDao">

    <resultMap id="OrderOperationMap" type="com.zm.order.tool.server.model.OrderOperation">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="role" jdbcType="INTEGER" property="role"/>
        <result column="operator" jdbcType="BIGINT" property="operator"/>
        <result column="before_status" jdbcType="INTEGER" property="beforeStatus"/>
        <result column="operation" jdbcType="VARCHAR" property="operation"/>
        <result column="after_status" jdbcType="INTEGER" property="afterStatus"/>
        <result column="operate_at" jdbcType="TIMESTAMP" property="operateAt"/>
        <result column="features" jdbcType="VARCHAR" property="features"/>
        <result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
        <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
        <result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
    </resultMap>


    <sql id="tb">
        order_operations
    </sql>

    <sql id="cols_all">
        id,
        <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
       user_id, order_no, role, operator, before_status, operation, after_status, operate_at,
        features, created_at, updated_at, is_deleted
    </sql>

    <sql id="values">
        #{id}, #{userId}, #{orderNo}, #{role}, #{operator},
        #{beforeStatus}, #{operation}, #{afterStatus}, #{operateAt},
        #{features}, now(), now(), 0
  </sql>


    <select id="selectList" parameterType="map" resultMap="OrderOperationMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        where
        <![CDATA[ created_at <= #{createdAtEnd} ]]>
        order by id
        limit ${start}, ${pageSize}
    </select>


    <delete id="deleteList" parameterType="list">
        delete
        from
        <include refid="tb"/>
        where
        id in
        <foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
            #{id}
        </foreach>

    </delete>

</mapper>