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

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.controller.admin.machine.vo.MachinePageReqVO;
import com.cf.imes.module.system.dal.dataobject.machinetemplate.MachineTemplateDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * @author there
 */
@Mapper
public interface MachineTemplateMapper extends BaseMapperX<MachineTemplateDO> {

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