package com.cf.imes.module.system.dal.mysql.machine;

import java.util.*;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.system.controller.admin.machine.vo.*;
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
import com.cf.imes.module.system.dal.dataobject.machinetemplate.MachineTemplateDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 机台 Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface MachineMapper extends BaseMapperX<MachineDO> {

    default PageResult<MachineDO> selectPage(MachinePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MachineDO>()
                .likeIfPresent(MachineDO::getName, reqVO.getName())
                .eqIfPresent(MachineDO::getMachineType, reqVO.getMachineType())
                .betweenIfPresent(MachineDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MachineDO::getCreateTime));
    }

    Page<OrganMachineResp> selectOrganMachinePage(@Param("page") Page<OrganMachineResp> respPage, @Param("vo") OrganMachinePage page);

    List<OrganMachineVO> selectOrganMachineList(Map<String, Object> map);

    OrganMachineResp selectOrganMachine(Long organId);

    default PageResult<MachineDO> selectPage(MachinePageReqVO pageParam, Collection<Long> ids) {
        return selectPage(pageParam, new LambdaQueryWrapperX<MachineDO>()
                .eqIfPresent(MachineDO::getMachineType, pageParam.getMachineType())
                .likeIfPresent(MachineDO::getName, pageParam.getName())
                .betweenIfPresent(MachineDO::getCreateTime, pageParam.getCreateTime())
                .orderByDesc(MachineDO::getCreateTime));
    };
}