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

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.VehicleGalleryPageReqVO;
import com.xindazhou.vehicle.dal.dataobject.gallery.VehicleGalleryDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 车辆图库 Mapper
 *
 * @author xindazhou
 */
@Mapper
public interface VehicleGalleryMapper extends BaseMapperX<VehicleGalleryDO> {

    default PageResult<VehicleGalleryDO> selectPage(VehicleGalleryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VehicleGalleryDO>()
                .eqIfPresent(VehicleGalleryDO::getCategory, reqVO.getCategory())
                .eqIfPresent(VehicleGalleryDO::getModel, reqVO.getModel())
                .geIfPresent(VehicleGalleryDO::getImageCount, reqVO.getImageCountMin())
                .leIfPresent(VehicleGalleryDO::getImageCount, reqVO.getImageCountMax())
                .betweenIfPresent(VehicleGalleryDO::getUpdateTime, reqVO.getUpdateTime())
                .orderByDesc(VehicleGalleryDO::getId));
    }

}

