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

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.vehiclemodel.vo.VehicleModelPageReqVO;
import cn.iocoder.yudao.module.asset.dal.dataobject.vehiclemodel.VehicleModelDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 车型参数 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VehicleModelMapper extends BaseMapperX<VehicleModelDO> {

    default PageResult<VehicleModelDO> selectPage(VehicleModelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VehicleModelDO>()
                .eqIfPresent(VehicleModelDO::getBrand, reqVO.getBrand())
                .eqIfPresent(VehicleModelDO::getModel, reqVO.getModel())
                .eqIfPresent(VehicleModelDO::getFuelType, reqVO.getFuelType())
                .orderByDesc(VehicleModelDO::getId));
    }

    default List<VehicleModelDO> selectListByBrand(String brand) {
        return selectList(VehicleModelDO::getBrand, brand);
    }

    default List<VehicleModelDO> selectListByModel(String model) {
        return selectList(VehicleModelDO::getModel, model);
    }

}
