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

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.iotstoragearea.vo.IotStorageAreaPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotstoragearea.IotStorageAreaDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
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 IotStorageAreaMapper extends BaseMapperX<IotStorageAreaDO> {

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

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

}