<?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.supplier.mapper.PrivateOrderMapper">
    <!-- 查询私人订制 -->
    <select id="getPrivateOrder" resultType="PrivateOrder">
        SELECT
        *
        FROM
        ( SELECT *, ROW_NUMBER ( ) OVER ( ORDER BY ID ) AS RowId FROM bus_private_ordering ) AS b
        WHERE
        RowId BETWEEN #{page} AND #{limit}
        AND uuid NOT IN (SELECT ordering_uuid FROM bus_ignore_supplier WHERE code = #{code})
        AND order_type = #{orderType}
        <if test="startTime != null and startTime !=''">
            and CONVERT (datetime, start_time) <![CDATA[ >= ]]> #{startTime} and CONVERT(datetime, end_time) <![CDATA[ <= ]]> #{endTime}
        </if>
    </select>
    <!-- 查询总条数 -->
    <select id="getPrivateOrderCount" resultType="int">
        select count(*) as count from bus_private_ordering where order_type = #{orderType}
    </select>
    <!-- 查询总条数 -->
    <insert id="addIgnore" parameterType="Ignore">
        insert into bus_ignore_supplier(uuid,code,ordering_uuid) values (#{uuid},#{code},#{orderingUuid})
    </insert>
    <!-- 查询指定报价单内容 -->
    <select id="getPrivateOrderById" resultType="PrivateOrder">
        select * from bus_private_ordering where uuid = #{uuid}
    </select>
</mapper>