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

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.inspect.item.vo.IotInspectItemPageReqVO;
import cn.iocoder.yudao.module.pms.controller.admin.inspect.route.vo.IotInspectRoutePageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectItemDO;
import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectRouteDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * 巡检项 Mapper
 *
 * @author 李鹏辉
 */
@Mapper
public interface IotInspectItemMapper extends BaseMapperX<IotInspectItemDO> {

    default PageResult<IotInspectItemDO> selectPage(IotInspectItemPageReqVO reqVO, Set<Long> classifies, Set<Long> deptIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotInspectItemDO>()
                .likeIfPresent(IotInspectItemDO::getItem, reqVO.getItem())
                .eqIfPresent(IotInspectItemDO::getStandard, reqVO.getStandard())
                .eqIfPresent(IotInspectItemDO::getSort, reqVO.getSort())
                .eqIfPresent(IotInspectItemDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotInspectItemDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(IotInspectItemDO::getDeptId, deptIds)
                .inIfPresent(IotInspectItemDO::getDeviceClassify, classifies)
                .eqIfPresent(IotInspectItemDO::getDeviceId, reqVO.getDeviceId())
                .orderByDesc(IotInspectItemDO::getId));
    }

    IPage<IotInspectItemDO> getRouteItem(IPage<IotInspectItemPageReqVO> page, @Param("reqVO")  IotInspectItemPageReqVO reqVO);
}
