package com.zt.plat.module.qms.business.bus.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.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.business.bus.controller.vo.*;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustDepartmentDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
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 BusinessSampleEntrustDepartmentMapper extends BaseMapperX<BusinessSampleEntrustDepartmentDO> {

    default PageResult<BusinessSampleEntrustDepartmentExtendRespVO> selectPage(BusinessSampleEntrustDepartmentPageReqVO reqVO) {
        return selectJoinPage(reqVO, BusinessSampleEntrustDepartmentExtendRespVO.class, new MPJLambdaWrapperX<BusinessSampleEntrustDepartmentDO>()
        		.leftJoin(BusinessSampleEntrustRegistrationDO.class, BusinessSampleEntrustRegistrationDO::getId, BusinessSampleEntrustDepartmentDO::getBusinessSampleEntrustRegistrationId)
        		.leftJoin(ConfigEntrustSourceDO.class, ConfigEntrustSourceDO::getId, BusinessSampleEntrustRegistrationDO::getConfigEntrustSourceId)
        		.selectAll(BusinessSampleEntrustDepartmentDO.class)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustId, BusinessSampleEntrustDepartmentExtendRespVO::getEntrustId)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustNumber, BusinessSampleEntrustDepartmentExtendRespVO::getEntrustNumber)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustUnit, BusinessSampleEntrustDepartmentExtendRespVO::getEntrustUnit)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getConfigEntrustSourceId, BusinessSampleEntrustDepartmentExtendRespVO::getConfigEntrustSourceId)
        		.selectAs(ConfigEntrustSourceDO::getName, BusinessSampleEntrustDepartmentExtendRespVO::getConfigEntrustSourceName)
        		.eqIfPresent(BusinessSampleEntrustDepartmentDO::getBusinessSampleEntrustRegistrationId, reqVO.getBusinessSampleEntrustRegistrationId())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getAssayDepartmentId, reqVO.getAssayDepartmentId())
                .likeIfPresent(BusinessSampleEntrustDepartmentDO::getAssayDepartmentName, reqVO.getAssayDepartmentName())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getAssayProject, reqVO.getAssayProject())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getAssayProjectUnit, reqVO.getAssayProjectUnit())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getDataTemplateId, reqVO.getDataTemplateId())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getDataTemplateKey, reqVO.getDataTemplateKey())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getAssayStatus, reqVO.getAssayStatus())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getAssayOperator, reqVO.getAssayOperator())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getAssayOperatorId, reqVO.getAssayOperatorId())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getIsReported, reqVO.getIsReported())
                .betweenIfPresent(BusinessSampleEntrustDepartmentDO::getReportTime, reqVO.getReportTime())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getReportOperator, reqVO.getReportOperator())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getReportOperatorId, reqVO.getReportOperatorId())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSampleEntrustDepartmentDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSampleEntrustDepartmentDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessSampleEntrustDepartmentDO::getId));
    }

	default List<BusinessSampleEntrustDepartmentDO> selectByBusinessSampleEntrustRegistrationId(Long businessSampleEntrustRegistrationId) {
		return selectList(new LambdaQueryWrapperX<BusinessSampleEntrustDepartmentDO>()
				.eq(BusinessSampleEntrustDepartmentDO::getBusinessSampleEntrustRegistrationId, businessSampleEntrustRegistrationId));
	}

	default List<BusinessSampleEntrustDepartmentDO> selectByBusinessSampleEntrustRegistrationIds(List<Long> businessSampleEntrustRegistrationIdList) {
		return selectList(new LambdaQueryWrapperX<BusinessSampleEntrustDepartmentDO>()
				.in(BusinessSampleEntrustDepartmentDO::getBusinessSampleEntrustRegistrationId, businessSampleEntrustRegistrationIdList));
	}
    
}