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

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.asset.controller.admin.vehicle.vo.VehiclePageReqVO;
import cn.iocoder.yudao.module.asset.dal.dataobject.vehicle.VehicleBaseDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 车辆基础信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VehicleBaseMapper extends BaseMapperX<VehicleBaseDO> {

    default PageResult<VehicleBaseDO> selectPage(VehiclePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VehicleBaseDO>()
                .likeIfPresent(VehicleBaseDO::getPlateNo, reqVO.getPlateNo())
                .likeIfPresent(VehicleBaseDO::getVin, reqVO.getVin())
                .eqIfPresent(VehicleBaseDO::getVehicleModelId, reqVO.getVehicleModelId())
                .orderByDesc(VehicleBaseDO::getId));
    }

    default List<VehicleBaseDO> selectList(VehiclePageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VehicleBaseDO>()
                .likeIfPresent(VehicleBaseDO::getPlateNo, reqVO.getPlateNo())
                .likeIfPresent(VehicleBaseDO::getVin, reqVO.getVin())
                .eqIfPresent(VehicleBaseDO::getVehicleModelId, reqVO.getVehicleModelId())
                .orderByDesc(VehicleBaseDO::getId));
    }

}
