package com.njzscloud.supervisory.biz.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njzscloud.supervisory.biz.pojo.entity.BizTruckEntity;
import com.njzscloud.supervisory.biz.pojo.result.SearchCompanyResult;
import com.njzscloud.supervisory.biz.pojo.result.SearchTruckResult;
import com.njzscloud.supervisory.biz.pojo.result.TruckCantDelResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 车辆信息
 */
@Mapper
public interface BizTruckMapper extends BaseMapper<BizTruckEntity> {

    @Select("SELECT company_id id FROM biz_driver WHERE user_id = #{userId}")
    SearchCompanyResult selectCompanyByUserId(@Param("userId") Long userId);

    IPage<SearchTruckResult> paging(Page<Object> page, @Param("ew") QueryWrapper<SearchTruckResult> ew);

    /**
     * 根据ID查询预警详情（包含关联信息）
     */
    SearchTruckResult selectDetailById(@Param("id") Long id);

    List<TruckCantDelResult> truckCantDel(@Param("ew") QueryWrapper<Object> ew);
}
