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

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pms.controller.admin.iotprojectinfo.vo.IotProjectInfoPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojectinfo.IotProjectInfoDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 项目信息 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotProjectInfoMapper extends BaseMapperX<IotProjectInfoDO> {

    default PageResult<IotProjectInfoDO> selectPage(IotProjectInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotProjectInfoDO>()
                .eqIfPresent(IotProjectInfoDO::getDeptId, reqVO.getDeptId())
                .likeIfPresent(IotProjectInfoDO::getManufactureName, reqVO.getManufactureName())
                .likeIfPresent(IotProjectInfoDO::getDeptName, reqVO.getDeptName())
                .likeIfPresent(IotProjectInfoDO::getContractName, reqVO.getContractName())
                .eqIfPresent(IotProjectInfoDO::getContractCode, reqVO.getContractCode())
                .eqIfPresent(IotProjectInfoDO::getWorkloadTotal, reqVO.getWorkloadTotal())
                .eqIfPresent(IotProjectInfoDO::getWorkloadFinish, reqVO.getWorkloadFinish())
                .betweenIfPresent(IotProjectInfoDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(IotProjectInfoDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(IotProjectInfoDO::getLocation, reqVO.getLocation())
                .eqIfPresent(IotProjectInfoDO::getTechnique, reqVO.getTechnique())
                .eqIfPresent(IotProjectInfoDO::getPayment, reqVO.getPayment())
                .betweenIfPresent(IotProjectInfoDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotProjectInfoDO::getUserName, reqVO.getUserName())
                .eqIfPresent(IotProjectInfoDO::getManufacturerId, reqVO.getManufacturerId())
                .eqIfPresent(IotProjectInfoDO::getUserId, reqVO.getUserId())
                .likeIfPresent(IotProjectInfoDO::getRemark, reqVO.getRemark())
                .orderByDesc(IotProjectInfoDO::getId));
    }

    default PageResult<IotProjectInfoDO> selectPage1(IotProjectInfoPageReqVO reqVO, Collection<Long> deptIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotProjectInfoDO>()
                .eqIfPresent(IotProjectInfoDO::getDeptId, reqVO.getCompanyDeptId())
                .eqIfPresent(IotProjectInfoDO::getProjectDeptId, reqVO.getProjectDeptId())
                .inIfPresent(IotProjectInfoDO::getProjectDeptId, reqVO.getProjectDeptIds())
                .inIfPresent(IotProjectInfoDO::getDeptId, deptIds)
                .likeIfPresent(IotProjectInfoDO::getManufactureName, reqVO.getManufactureName())
                .likeIfPresent(IotProjectInfoDO::getDeptName, reqVO.getDeptName())
                .likeIfPresent(IotProjectInfoDO::getContractName, reqVO.getContractName())
                .eqIfPresent(IotProjectInfoDO::getContractCode, reqVO.getContractCode())
                .eqIfPresent(IotProjectInfoDO::getWorkloadTotal, reqVO.getWorkloadTotal())
                .eqIfPresent(IotProjectInfoDO::getWorkloadFinish, reqVO.getWorkloadFinish())
                .betweenIfPresent(IotProjectInfoDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(IotProjectInfoDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(IotProjectInfoDO::getLocation, reqVO.getLocation())
                .eqIfPresent(IotProjectInfoDO::getTechnique, reqVO.getTechnique())
                .eqIfPresent(IotProjectInfoDO::getPayment, reqVO.getPayment())
                .betweenIfPresent(IotProjectInfoDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotProjectInfoDO::getUserName, reqVO.getUserName())
                .eqIfPresent(IotProjectInfoDO::getManufacturerId, reqVO.getManufacturerId())
                .eqIfPresent(IotProjectInfoDO::getUserId, reqVO.getUserId())
                .likeIfPresent(IotProjectInfoDO::getRemark, reqVO.getRemark())
                .orderByDesc(IotProjectInfoDO::getId));
    }

    default List<IotProjectInfoDO> selectList(IotProjectInfoPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotProjectInfoDO>()
                .inIfPresent(IotProjectInfoDO::getId,  reqVO.getProjectIds())
                .eqIfPresent(IotProjectInfoDO::getDeptId, reqVO.getDeptId())
                .likeIfPresent(IotProjectInfoDO::getManufactureName, reqVO.getManufactureName())
                .likeIfPresent(IotProjectInfoDO::getDeptName, reqVO.getDeptName())
                .likeIfPresent(IotProjectInfoDO::getContractName, reqVO.getContractName())
                .eqIfPresent(IotProjectInfoDO::getContractCode, reqVO.getContractCode())
                .eqIfPresent(IotProjectInfoDO::getWorkloadTotal, reqVO.getWorkloadTotal())
                .eqIfPresent(IotProjectInfoDO::getWorkloadFinish, reqVO.getWorkloadFinish())
                .betweenIfPresent(IotProjectInfoDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(IotProjectInfoDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(IotProjectInfoDO::getLocation, reqVO.getLocation())
                .eqIfPresent(IotProjectInfoDO::getTechnique, reqVO.getTechnique())
                .eqIfPresent(IotProjectInfoDO::getPayment, reqVO.getPayment())
                .betweenIfPresent(IotProjectInfoDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotProjectInfoDO::getUserName, reqVO.getUserName())
                .eqIfPresent(IotProjectInfoDO::getManufacturerId, reqVO.getManufacturerId())
                .eqIfPresent(IotProjectInfoDO::getUserId, reqVO.getUserId())
                .likeIfPresent(IotProjectInfoDO::getRemark, reqVO.getRemark()));
    }

    default List<IotProjectInfoDO> sortedProjects(IotProjectInfoPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotProjectInfoDO>()
                .inIfPresent(IotProjectInfoDO::getId,  reqVO.getProjectIds())
                .eqIfPresent(IotProjectInfoDO::getDeptId, reqVO.getDeptId())
                .likeIfPresent(IotProjectInfoDO::getManufactureName, reqVO.getManufactureName())
                .likeIfPresent(IotProjectInfoDO::getDeptName, reqVO.getDeptName())
                .likeIfPresent(IotProjectInfoDO::getContractName, reqVO.getContractName())
                .eqIfPresent(IotProjectInfoDO::getContractCode, reqVO.getContractCode())
                .eqIfPresent(IotProjectInfoDO::getWorkloadTotal, reqVO.getWorkloadTotal())
                .eqIfPresent(IotProjectInfoDO::getWorkloadFinish, reqVO.getWorkloadFinish())
                .betweenIfPresent(IotProjectInfoDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(IotProjectInfoDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(IotProjectInfoDO::getLocation, reqVO.getLocation())
                .eqIfPresent(IotProjectInfoDO::getTechnique, reqVO.getTechnique())
                .eqIfPresent(IotProjectInfoDO::getPayment, reqVO.getPayment())
                .betweenIfPresent(IotProjectInfoDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotProjectInfoDO::getUserName, reqVO.getUserName())
                .eqIfPresent(IotProjectInfoDO::getManufacturerId, reqVO.getManufacturerId())
                .eqIfPresent(IotProjectInfoDO::getUserId, reqVO.getUserId())
                .likeIfPresent(IotProjectInfoDO::getRemark, reqVO.getRemark())
                .orderByDesc(IotProjectInfoDO::getCreateTime));
    }

    List<IotProjectInfoDO> projectList();
}