package com.zt.plat.module.qms.resource.device.dal.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.qms.resource.device.controller.vo.*;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceMaintainDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 设备-点检、保养记录 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface DeviceMaintainMapper extends BaseMapperX<DeviceMaintainDO> {

    default PageResult<DeviceMaintainDO> selectPage(DeviceMaintainPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceMaintainDO>()
                .eqIfPresent(DeviceMaintainDO::getDataType, reqVO.getDataType())
                .eqIfPresent(DeviceMaintainDO::getRuleId, reqVO.getRuleId())
                .eqIfPresent(DeviceMaintainDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(DeviceMaintainDO::getCheckDate, reqVO.getCheckDate())
                .eqIfPresent(DeviceMaintainDO::getContent, reqVO.getContent())
                .eqIfPresent(DeviceMaintainDO::getCheckUserId, reqVO.getCheckUserId())
                .likeIfPresent(DeviceMaintainDO::getCheckUserName, reqVO.getCheckUserName())
                .eqIfPresent(DeviceMaintainDO::getFrequencyType, reqVO.getFrequencyType())
                .eqIfPresent(DeviceMaintainDO::getFrequency, reqVO.getFrequency())
                .eqIfPresent(DeviceMaintainDO::getFrequencyRemark, reqVO.getFrequencyRemark())
                .eqIfPresent(DeviceMaintainDO::getFrequencyTimeStart, reqVO.getFrequencyTimeStart())
                .eqIfPresent(DeviceMaintainDO::getFrequencyTimeEnd, reqVO.getFrequencyTimeEnd())
                .eqIfPresent(DeviceMaintainDO::getSubmitFlag, reqVO.getSubmitFlag())
                .eqIfPresent(DeviceMaintainDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(DeviceMaintainDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DeviceMaintainDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceMaintainDO::getId));
    }

//    IPage<DeviceMaintainVO> queryPageListWithCount(Page<DeviceMaintainVO> page, @Param("param") DeviceMaintainPageReqVO param);
//    DeviceMaintainVO queryVoById(@Param("id") Long id);

    IPage<DeviceInfomationMaintainVO> queryPageListWithCount(Page<DeviceInfomationMaintainVO> page, @Param("param") DeviceMaintainPageReqVO param);

}