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

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.BusinessAssayTaskDetailDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;

/**
 * 检测任务分配明细 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface BusinessAssayTaskDetailMapper extends BaseMapperX<BusinessAssayTaskDetailDO> {

    default PageResult<BusinessAssayTaskDetailDO> selectPage(BusinessAssayTaskDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BusinessAssayTaskDetailDO>()
                .eqIfPresent(BusinessAssayTaskDetailDO::getBusinessAssayTaskId, reqVO.getBusinessAssayTaskId())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSampleId, reqVO.getSampleId())
                .eqIfPresent(BusinessAssayTaskDetailDO::getTaskNo, reqVO.getTaskNo())
                .likeIfPresent(BusinessAssayTaskDetailDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessAssayTaskDetailDO::getCupNumber, reqVO.getCupNumber())
                .eqIfPresent(BusinessAssayTaskDetailDO::getDataSourceType, reqVO.getDataSourceType())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSortNo, reqVO.getSortNo())
                .eqIfPresent(BusinessAssayTaskDetailDO::getRollbackStatus, reqVO.getRollbackStatus())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessAssayTaskDetailDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessAssayTaskDetailDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessAssayTaskDetailDO::getId));
    }
    
    default List<BusinessAssayTaskDetailExtendRespVO> selectList(BusinessAssayTaskDetailReqVO reqVO) {
    	return selectJoinList(BusinessAssayTaskDetailExtendRespVO.class, new MPJLambdaWrapperX<BusinessAssayTaskDetailDO>()
                .eqIfPresent(BusinessAssayTaskDetailDO::getBusinessAssayTaskId, reqVO.getBusinessAssayTaskId())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSampleId, reqVO.getSampleId())
                .eqIfPresent(BusinessAssayTaskDetailDO::getTaskNo, reqVO.getTaskNo())
                .likeIfPresent(BusinessAssayTaskDetailDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessAssayTaskDetailDO::getCupNumber, reqVO.getCupNumber())
                .eqIfPresent(BusinessAssayTaskDetailDO::getDataSourceType, reqVO.getDataSourceType())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSortNo, reqVO.getSortNo())
                .eqIfPresent(BusinessAssayTaskDetailDO::getRollbackStatus, reqVO.getRollbackStatus())
                .eqIfPresent(BusinessAssayTaskDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessAssayTaskDetailDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessAssayTaskDetailDO::getRemark, reqVO.getRemark())
    			.orderByDesc(BusinessAssayTaskDetailDO::getId));
    }

	default List<BusinessAssayTaskDetailDO> selectByBusinessAssayTaskId(Long businessAssayTaskId) {
		return selectList(new LambdaQueryWrapperX<BusinessAssayTaskDetailDO>()
                .eqIfPresent(BusinessAssayTaskDetailDO::getBusinessAssayTaskId, businessAssayTaskId));
	}

}