<?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.tempdb.IdOrderNoFixDao">

    <resultMap id="IdOrderMap" type="com.zm.order.tool.server.model.IdOrderNoFix">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <id column="order_id" jdbcType="BIGINT" property="orderId"/>
        <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
    </resultMap>

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

    <sql id="cols_with_id">
        id,
        order_id,
        order_no,
        user_id
    </sql>

    <sql id="cols_all">
        id,
        order_id,
        order_no,
        user_id
    </sql>

    <select id="selectListById" parameterType="map" resultMap="IdOrderMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            <if test="lastId != null">
                id > #{lastId}
            </if>
        </where>
        order by id asc limit 200
    </select>

    <select id="selectListByIdSize" parameterType="map"  resultMap="IdOrderMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        <where>
            <if test="lastId != null">
                id > #{lastId}
            </if>
        </where>
        order by id asc limit #{size}
    </select>

    <select id="selectOne" parameterType="map" resultMap="IdOrderMap">
        select
        <include refid="cols_all"/>
        from
        <include refid="tb"/>
        where order_no = #{orderNo}
    </select>

</mapper>