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

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

/**
 * 车辆上牌记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VehicleRegistrationMapper extends BaseMapperX<VehicleRegistrationDO> {

    default PageResult<VehicleRegistrationDO> selectPage(VehicleRegistrationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VehicleRegistrationDO>()
                .eqIfPresent(VehicleRegistrationDO::getVehicleId, reqVO.getVehicleId())
                .likeIfPresent(VehicleRegistrationDO::getVin, reqVO.getVin())
                .likeIfPresent(VehicleRegistrationDO::getPlateNo, reqVO.getPlateNo())
                .betweenIfPresent(VehicleRegistrationDO::getPlateDate, reqVO.getPlateDateStart(), reqVO.getPlateDateEnd())
                .likeIfPresent(VehicleRegistrationDO::getOperator, reqVO.getOperator())
                .eqIfPresent(VehicleRegistrationDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(VehicleRegistrationDO::getCreateTime, reqVO.getCreateTimeStart(), reqVO.getCreateTimeEnd())
                .orderByDesc(VehicleRegistrationDO::getId));
    }

}
