package com.ningdatech.carapi.car.equipment.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.carapi.car.equipment.model.NdVehicleEquipmentJoin;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-10-12
 */
public interface NdVehicleEquipmentJoinMapper extends BaseMapper<NdVehicleEquipmentJoin> {
    String QUERY_SQL = "SELECT eq.*,b.vehicle_type,c.id as company_id,c.name as company_name,o.name as operator_name," +
            "c.region_id,b.audit_state" +
            " FROM nd_vehicle_equipment_info AS eq " +
            " LEFT JOIN nd_vehicle_base_info AS b ON eq.vehicle_id = b.id " +
            " LEFT JOIN nd_company_info AS c ON b.company_id = c.id " +
            " LEFT JOIN nd_operator_info AS o ON b.operator_id = o.id ";
            String WRAPPER_SQL = "SELECT * from ( " + QUERY_SQL + " ) AS q ${ew.customSqlSegment}";

    @Select(WRAPPER_SQL)
    Page<NdVehicleEquipmentJoin> pageJoinBaseInfo(Page<NdVehicleEquipmentJoin> page, @Param("ew") LambdaQueryWrapper<NdVehicleEquipmentJoin> wrapper);
}
