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

import java.util.*;

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.dal.dataobject.ConfigEntrustSourceDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;

/**
 * 检验委托来源配置 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ConfigEntrustSourceMapper extends BaseMapperX<ConfigEntrustSourceDO> {

    default PageResult<ConfigEntrustSourceDO> selectPage(ConfigEntrustSourcePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConfigEntrustSourceDO>()
        		.eqIfPresent(ConfigEntrustSourceDO::getEntrustType, reqVO.getEntrustType())
                .likeIfPresent(ConfigEntrustSourceDO::getName, reqVO.getName())
                .eqIfPresent(ConfigEntrustSourceDO::getKey, reqVO.getKey())
                .eqIfPresent(ConfigEntrustSourceDO::getDataCollectionKey, reqVO.getDataCollectionKey())
                .eqIfPresent(ConfigEntrustSourceDO::getConfigReportTemplateKey, reqVO.getConfigReportTemplateKey())
                .eqIfPresent(ConfigEntrustSourceDO::getCodeRule, reqVO.getCodeRule())
                .eqIfPresent(ConfigEntrustSourceDO::getCodeField, reqVO.getCodeField())
                .eqIfPresent(ConfigEntrustSourceDO::getIsGenerateDocument, reqVO.getIsGenerateDocument())
                .eqIfPresent(ConfigEntrustSourceDO::getDataTemplateKey, reqVO.getDataTemplateKey())
                .eqIfPresent(ConfigEntrustSourceDO::getEntrustWay, reqVO.getEntrustWay())
                .inIfPresent(ConfigEntrustSourceDO::getEntrustWay, reqVO.getEntrustWayList())
                .eqIfPresent(ConfigEntrustSourceDO::getEntrustSubmitWay, reqVO.getEntrustSubmitWay())
                .eqIfPresent(ConfigEntrustSourceDO::getExternalConfig, reqVO.getExternalConfig())
                .eqIfPresent(ConfigEntrustSourceDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(ConfigEntrustSourceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConfigEntrustSourceDO::getRemark, reqVO.getRemark())
                .orderByDesc(ConfigEntrustSourceDO::getId));
    }
    
    default List<ConfigEntrustSourceDO> selectList(ConfigEntrustSourceReqVO reqVO) {
    	return selectList(new LambdaQueryWrapperX<ConfigEntrustSourceDO>()
    			.eqIfPresent(ConfigEntrustSourceDO::getEntrustType, reqVO.getEntrustType())
                .likeIfPresent(ConfigEntrustSourceDO::getName, reqVO.getName())
                .eqIfPresent(ConfigEntrustSourceDO::getKey, reqVO.getKey())
                .eqIfPresent(ConfigEntrustSourceDO::getDataCollectionKey, reqVO.getDataCollectionKey())
                .eqIfPresent(ConfigEntrustSourceDO::getConfigReportTemplateKey, reqVO.getConfigReportTemplateKey())
                .eqIfPresent(ConfigEntrustSourceDO::getCodeRule, reqVO.getCodeRule())
                .eqIfPresent(ConfigEntrustSourceDO::getCodeField, reqVO.getCodeField())
                .eqIfPresent(ConfigEntrustSourceDO::getIsGenerateDocument, reqVO.getIsGenerateDocument())
                .eqIfPresent(ConfigEntrustSourceDO::getDataTemplateKey, reqVO.getDataTemplateKey())
                .eqIfPresent(ConfigEntrustSourceDO::getEntrustWay, reqVO.getEntrustWay())
                .inIfPresent(ConfigEntrustSourceDO::getEntrustWay, reqVO.getEntrustWayList())
                .eqIfPresent(ConfigEntrustSourceDO::getEntrustSubmitWay, reqVO.getEntrustSubmitWay())
                .eqIfPresent(ConfigEntrustSourceDO::getExternalConfig, reqVO.getExternalConfig())
                .eqIfPresent(ConfigEntrustSourceDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(ConfigEntrustSourceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConfigEntrustSourceDO::getRemark, reqVO.getRemark())
                .orderByDesc(ConfigEntrustSourceDO::getId));
    }

	default ConfigEntrustSourceDO selectBySourceKeyAndEntrustType(String configEntrustSourceKey, String entrustType) {
		return selectOne(new LambdaQueryWrapperX<ConfigEntrustSourceDO>()
				.eq(ConfigEntrustSourceDO::getKey, configEntrustSourceKey)
				.eq(ConfigEntrustSourceDO::getEntrustType, entrustType));
	}

}