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.controller.vo.BusinessSampleEntrustDetailExtendRespVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSampleEntrustDetailPageReqVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSampleEntrustDetailReqVO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustDetailDO;
import com.zt.plat.module.qms.business.config.dal.dataobject.BaseSampleDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 委检登记样品明细 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface BusinessSampleEntrustDetailMapper extends BaseMapperX<BusinessSampleEntrustDetailDO> {

	default List<BusinessSampleEntrustDetailExtendRespVO> selectList(BusinessSampleEntrustDetailReqVO reqVO) {
		return selectJoinList(BusinessSampleEntrustDetailExtendRespVO.class, new MPJLambdaWrapperX<BusinessSampleEntrustDetailDO>()
				.leftJoin(BaseSampleDO.class, BaseSampleDO::getId, BusinessSampleEntrustDetailDO::getBaseSampleId)
				.selectAll(BusinessSampleEntrustDetailDO.class)
				.selectAs(BaseSampleDO::getName, BusinessSampleEntrustDetailExtendRespVO::getBaseSampleName)
                .eqIfPresent(BusinessSampleEntrustDetailDO::getBusinessSampleEntrustRegistrationId, reqVO.getBusinessSampleEntrustRegistrationId())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getBaseSampleId, reqVO.getBaseSampleId())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSampleTypeDictionaryBusinessId, reqVO.getSampleTypeDictionaryBusinessId())
                .likeIfPresent(BusinessSampleEntrustDetailDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSampleCode, reqVO.getSampleCode())
                .likeIfPresent(BusinessSampleEntrustDetailDO::getEntrustSampleName, reqVO.getEntrustSampleName())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getEntrustSampleCode, reqVO.getEntrustSampleCode())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSort, reqVO.getSort())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getAssayProject, reqVO.getAssayProject())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getForecastResult, reqVO.getForecastResult())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getIsWeighing, reqVO.getIsWeighing())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSampleEntrustDetailDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessSampleEntrustDetailDO::getId));
	}

    default PageResult<BusinessSampleEntrustDetailExtendRespVO> selectPage(BusinessSampleEntrustDetailPageReqVO reqVO) {
        return selectJoinPage(reqVO, BusinessSampleEntrustDetailExtendRespVO.class, new MPJLambdaWrapperX<BusinessSampleEntrustDetailDO>()
				.leftJoin(BaseSampleDO.class, BaseSampleDO::getId, BusinessSampleEntrustDetailDO::getBaseSampleId)
				.selectAll(BusinessSampleEntrustDetailDO.class)
				.selectAs(BaseSampleDO::getName, BusinessSampleEntrustDetailExtendRespVO::getBaseSampleName)
                .eqIfPresent(BusinessSampleEntrustDetailDO::getBusinessSampleEntrustRegistrationId, reqVO.getBusinessSampleEntrustRegistrationId())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getBaseSampleId, reqVO.getBaseSampleId())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSampleTypeDictionaryBusinessId, reqVO.getSampleTypeDictionaryBusinessId())
                .likeIfPresent(BusinessSampleEntrustDetailDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSampleCode, reqVO.getSampleCode())
                .likeIfPresent(BusinessSampleEntrustDetailDO::getEntrustSampleName, reqVO.getEntrustSampleName())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getEntrustSampleCode, reqVO.getEntrustSampleCode())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSort, reqVO.getSort())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getAssayProject, reqVO.getAssayProject())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getForecastResult, reqVO.getForecastResult())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getIsWeighing, reqVO.getIsWeighing())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSampleEntrustDetailDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSampleEntrustDetailDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessSampleEntrustDetailDO::getId));
    }

    /**
     * 物理批量删除删除
     * @param idList
     * @return
     */
    int physicalDeleteByIds(@Param("idList") List<Long> idList);

}