package cn.iocoder.yudao.module.smartfactory.dal.mysql.factoryforklift;

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.smartfactory.controller.admin.factoryforklift.vo.FactoryForkliftPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryforklift.vo.FactoryForkliftRespVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryforklift.FactoryForkliftDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 叉车管理 Mapper
 *
 * @author 姚君
 */
@Mapper
public interface FactoryForkliftMapper extends BaseMapperX<FactoryForkliftDO> {

    default PageResult<FactoryForkliftDO> selectPage(FactoryForkliftPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FactoryForkliftDO>()
                .eqIfPresent(FactoryForkliftDO::getAssetsNo, reqVO.getAssetsNo())
                .eqIfPresent(FactoryForkliftDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(FactoryForkliftDO::getDeptId, reqVO.getDeptId())
                .likeIfPresent(FactoryForkliftDO::getName, reqVO.getName())
                .eqIfPresent(FactoryForkliftDO::getManufacturer, reqVO.getManufacturer())
                .eqIfPresent(FactoryForkliftDO::getModelNo, reqVO.getModelNo())
                .eqIfPresent(FactoryForkliftDO::getLicensePlate, reqVO.getLicensePlate())
                .betweenIfPresent(FactoryForkliftDO::getNameplateDate, reqVO.getNameplateDate())
                .eqIfPresent(FactoryForkliftDO::getUseType, reqVO.getUseType())
                .betweenIfPresent(FactoryForkliftDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FactoryForkliftDO::getId));
    }

    /**
     * 叉车列表
     *
     * @param pageReqVO
     * @param objectPage
     * @return
     */
    IPage<FactoryForkliftRespVO> getFactoryForkliftPage(@Param("vo") FactoryForkliftPageReqVO pageReqVO, @Param("page") Page<Object> objectPage);

    /**
     * 通过工厂ids 和 资产类型ids 获取叉车列表
     *
     * @param factoryIds
     * @param typeIds
     * @return
     */
    List<FactoryForkliftRespVO> getFactoryForkliftByFactoryIdAndTypeIds(@Param("factoryIds") List<Long> factoryIds, @Param("typeIds") List<Long> typeIds);
}
