package com.cpxt.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cpxt.biz.domain.BizCar;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 车辆Mapper接口
 * 
 * @author YIN
 * @date 2024-12-16
 */
@Mapper
public interface BizCarMapper extends BaseMapper<BizCar>
{
    @Update("create table ${tableName} as select * from track_temp")
    void createTable(String tableName);

    @Update("ALTER TABLE ${tableName} MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT")
    void setAutoIncrement(String tableName);

    @Update("ALTER TABLE ${tableName} ADD PRIMARY KEY (id)")
    void addPrimaryKey(String tableName);

    @Select("select * from biz_car where car_no = #{carNo}")
    BizCar selectByCarNo(String carNo);

    @Select("select * from biz_car where serial_no = #{serialNo}")
    BizCar selectBySerialNo(String serialNo);

    @Select("select * from ${tableName} where gps_time >= #{startTime} and gps_time <= #{endTime}")
    List<Map> selectBizTrackList(@Param("tableName") String tableName,@Param("startTime") String startTime,@Param("endTime") String endTime);

}
