package cn.iocoder.yudao.module.asset.dal.mysql.inspection;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.asset.dal.dataobject.inspection.InspectionRecordDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 验车记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface InspectionRecordMapper extends BaseMapperX<InspectionRecordDO> {

    default InspectionRecordDO selectLatestByVehicleAndSourceType(Long vehicleId, Integer sourceType) {
        return selectOne(new LambdaQueryWrapperX<InspectionRecordDO>()
                .eq(InspectionRecordDO::getVehicleId, vehicleId)
                .eq(InspectionRecordDO::getSourceType, sourceType)
                .eq(InspectionRecordDO::getStatus, 2)
                .orderByDesc(InspectionRecordDO::getId)
                .last("LIMIT 1"));
    }

}
