package com.xindazhou.vehicle.dal.mysql.archive;

import com.xindazhou.framework.common.pojo.PageResult;
import com.xindazhou.framework.mybatis.core.mapper.BaseMapperX;
import com.xindazhou.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.xindazhou.vehicle.controller.admin.vehicle.vo.VehicleArchivePageReqVO;
import com.xindazhou.vehicle.dal.dataobject.archive.VehicleArchiveDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 车辆档案 Mapper
 *
 * @author xindazhou
 */
@Mapper
public interface VehicleArchiveMapper extends BaseMapperX<VehicleArchiveDO> {

    default PageResult<VehicleArchiveDO> selectPage(VehicleArchivePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VehicleArchiveDO>()
                .likeIfPresent(VehicleArchiveDO::getVin, reqVO.getVin())
                .likeIfPresent(VehicleArchiveDO::getOwnerName, reqVO.getOwnerName())
                .likeIfPresent(VehicleArchiveDO::getOwnerMobile, reqVO.getOwnerMobile())
                .eqIfPresent(VehicleArchiveDO::getCategory, reqVO.getCategory())
                .eqIfPresent(VehicleArchiveDO::getModel, reqVO.getModel())
                .eqIfPresent(VehicleArchiveDO::getActivationStatus, reqVO.getActivationStatus())
                .eqIfPresent(VehicleArchiveDO::getTheftStatus, reqVO.getTheftStatus())
                .betweenIfPresent(VehicleArchiveDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(VehicleArchiveDO::getId));
    }

}

