package com.zt.plat.module.qms.business.config.dal.mapper;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.qms.business.config.controller.vo.*;
import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSamplePageReqVO;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;

/**
 * 子样配置 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ConfigSubSampleMapper extends BaseMapperX<ConfigSubSampleDO> {

    default PageResult<ConfigSubSampleDO> selectPage(ConfigSubSamplePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConfigSubSampleDO>()
                .eqIfPresent(ConfigSubSampleDO::getBaseSampleId, reqVO.getBaseSampleId())
                .eqIfPresent(ConfigSubSampleDO::getConfigBaseSampleId, reqVO.getConfigBaseSampleId())
                .eqIfPresent(ConfigSubSampleDO::getConfigSubSampleParentId, reqVO.getConfigSubSampleParentId())
                .eqIfPresent(ConfigSubSampleDO::getDictionaryBusinessId, reqVO.getDictionaryBusinessId())
                .eqIfPresent(ConfigSubSampleDO::getFlowKey, reqVO.getFlowKey())
                .eqIfPresent(ConfigSubSampleDO::getIsGenerateSimpleCode, reqVO.getIsGenerateSimpleCode())
                .eqIfPresent(ConfigSubSampleDO::getSimpleCodeRule, reqVO.getSimpleCodeRule())
                .eqIfPresent(ConfigSubSampleDO::getCodeRule, reqVO.getCodeRule())
                .eqIfPresent(ConfigSubSampleDO::getPrintTemplate, reqVO.getPrintTemplate())
                .eqIfPresent(ConfigSubSampleDO::getCodePrintQuantity, reqVO.getCodePrintQuantity())
                .eqIfPresent(ConfigSubSampleDO::getIsPrint, reqVO.getIsPrint())
                .eqIfPresent(ConfigSubSampleDO::getRecheckFlowNodeKey, reqVO.getRecheckFlowNodeKey())
                .likeIfPresent(ConfigSubSampleDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(ConfigSubSampleDO::getSampleSaveDay, reqVO.getSampleSaveDay())
                .eqIfPresent(ConfigSubSampleDO::getConfigWarehouseLocationCode, reqVO.getConfigWarehouseLocationCode())
                .eqIfPresent(ConfigSubSampleDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(ConfigSubSampleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConfigSubSampleDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ConfigSubSampleDO::getVersion, reqVO.getVersion())
                .orderByDesc(ConfigSubSampleDO::getId));
    }
    
    default List<ConfigSubSampleDO> selectByBaseSampleIds(List<Long> baseSampleIds) {
    	return selectList(new LambdaQueryWrapperX<ConfigSubSampleDO>()
    			.in(ConfigSubSampleDO::getBaseSampleId, baseSampleIds));
    }

}