package com.njzscloud.supervisory.biz.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
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.BizDriverEntity;
import com.njzscloud.supervisory.biz.pojo.result.DriverCantDelResult;
import com.njzscloud.supervisory.biz.pojo.result.SearchCompanyResult;
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 BizDriverMapper extends BaseMapper<BizDriverEntity> {
    @Select("SELECT id,uscc,company_name FROM biz_company WHERE user_id = #{userId}")
    SearchCompanyResult selectCompanyByUserId(@Param("userId") Long userId);

    /**
     * 分页查询司机信息，包含清运公司名称
     *
     * @param page         分页参数
     * @param queryWrapper 查询条件
     * @return 分页结果
     */
    IPage<BizDriverEntity> selectPageWithCompanyName(Page<BizDriverEntity> page, @Param("ew") Wrapper<BizDriverEntity> queryWrapper);

    @Select("SELECT id,uscc,company_name FROM biz_company WHERE id = #{companyId}")
    SearchCompanyResult selectCompanyById(@Param("companyId") Long companyId);

    List<DriverCantDelResult> driverCantDel(@Param("ew") QueryWrapper<Object> ew);
}
