<?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="cn.iocoder.yudao.module.booking.mapper.DlRepairBookingMapper">

    <resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.booking.entity.DlRepairBooking">
            <id property="id" column="id" jdbcType="VARCHAR"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="userName" column="user_name" jdbcType="VARCHAR"/>
            <result property="userMobile" column="user_mobile" jdbcType="VARCHAR"/>
            <result property="projectId" column="project_id" jdbcType="VARCHAR"/>
            <result property="carId" column="car_id" jdbcType="VARCHAR"/>
            <result property="carNo" column="car_no" jdbcType="VARCHAR"/>
            <result property="ticketsId" column="tickets_id" jdbcType="VARCHAR"/>
            <result property="bookingStatus" column="booking_status" jdbcType="VARCHAR"/>
            <result property="bookingTime" column="booking_time" jdbcType="TIMESTAMP"/>
            <result property="corpId" column="corp_id" jdbcType="VARCHAR"/>
            <result property="deptId" column="dept_id" jdbcType="BIGINT"/>
    </resultMap>

    <sql id="Base_SQL">
        select id,
               user_id,
               user_name,
               user_mobile,
               project_id,
               car_id,
               car_no,
               booking_time,
               corp_id,
               dept_id,
               tickets_id,
               booking_status
        from dl_repair_booking drb
        where drb.deleted = '0'
    </sql>

    <select id="getBookingPage" resultMap="BaseResultMap">
        <include refid="Base_SQL" />
        <if test="map.userId != null and map.userId != ''">
            and drb.user_id = #{map.userId}
        </if>
        <if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
            and (drb.booking_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]})
        </if>
        <if test="map.carNo != null and map.carNo != ''">
            and drb.car_no = #{map.carNo}
        </if>
        order by drb.create_time desc
    </select>
</mapper>
