package cn.iocoder.yudao.module.pms.dal.mysql.iotshelves;

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.pms.controller.admin.iotshelves.vo.IotShelvesPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotshelves.IotShelvesDO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotstoragearea.IotStorageAreaDO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.lang.Nullable;

import java.util.Collection;
import java.util.List;

/**
 * PMS 货架 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotShelvesMapper extends BaseMapperX<IotShelvesDO> {

    default PageResult<IotShelvesDO> selectPage(IotShelvesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotShelvesDO>()
                .eqIfPresent(IotShelvesDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(IotShelvesDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(IotShelvesDO::getFactoryCode, reqVO.getFactoryCode())
                .likeIfPresent(IotShelvesDO::getFactoryName, reqVO.getFactoryName())
                .eqIfPresent(IotShelvesDO::getCostCenterId, reqVO.getCostCenterId())
                .eqIfPresent(IotShelvesDO::getCostCenterCode, reqVO.getCostCenterCode())
                .eqIfPresent(IotShelvesDO::getStorageLocationId, reqVO.getStorageLocationId())
                .eqIfPresent(IotShelvesDO::getStorageLocationCode, reqVO.getStorageLocationCode())
                .eqIfPresent(IotShelvesDO::getStorageAreaId, reqVO.getStorageAreaId())
                .eqIfPresent(IotShelvesDO::getCode, reqVO.getCode())
                .likeIfPresent(IotShelvesDO::getName, reqVO.getName())
                .eqIfPresent(IotShelvesDO::getType, reqVO.getType())
                .eqIfPresent(IotShelvesDO::getSort, reqVO.getSort())
                .eqIfPresent(IotShelvesDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotShelvesDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotShelvesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotShelvesDO::getId));
    }

    default List<IotShelvesDO> selectListByStatus(@Nullable Collection<Integer> statuses) {
        return selectList(IotShelvesDO::getStatus, statuses);
    }

}