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.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.business.config.controller.vo.*;
import com.zt.plat.module.qms.business.config.controller.vo.MaterialAssayStandardForecastProjectPageReqVO;
import com.zt.plat.module.qms.business.config.dal.dataobject.MaterialAssayStandardDO;
import com.zt.plat.module.qms.business.config.dal.dataobject.MaterialAssayStandardForecastProjectDO;
import com.zt.plat.module.qms.business.dic.dal.dataobject.DictionaryProjectDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;

/**
 * 物料检测标准来样品位配置 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface MaterialAssayStandardForecastProjectMapper extends BaseMapperX<MaterialAssayStandardForecastProjectDO> {

    default PageResult<MaterialAssayStandardForecastProjectDO> selectPage(MaterialAssayStandardForecastProjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialAssayStandardForecastProjectDO>()
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getMaterialAssayStandardId, reqVO.getMaterialAssayStandardId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDictionaryProjectId, reqVO.getDictionaryProjectId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDictionaryProjectCode, reqVO.getDictionaryProjectCode())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getUnitId, reqVO.getUnitId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getUnit, reqVO.getUnit())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDataType, reqVO.getDataType())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDecimalPosition, reqVO.getDecimalPosition())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getIsDefault, reqVO.getIsDefault())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(MaterialAssayStandardForecastProjectDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getRemark, reqVO.getRemark())
                .orderByDesc(MaterialAssayStandardForecastProjectDO::getId));
    }
    
    
    default List<MaterialAssayStandardForecastProjectExtendRespVO> selectList(MaterialAssayStandardForecastProjectReqVO reqVO) {
    	return selectJoinList(MaterialAssayStandardForecastProjectExtendRespVO.class, new MPJLambdaWrapperX<MaterialAssayStandardForecastProjectDO>()
				.leftJoin(DictionaryProjectDO.class, DictionaryProjectDO::getId, MaterialAssayStandardForecastProjectDO::getDictionaryProjectId)
				.leftJoin(MaterialAssayStandardDO.class, MaterialAssayStandardDO::getId, MaterialAssayStandardForecastProjectDO::getMaterialAssayStandardId)
				.selectAll(MaterialAssayStandardForecastProjectDO.class)
				.selectAs(DictionaryProjectDO::getKey, MaterialAssayStandardForecastProjectExtendRespVO::getDictionaryProjectKey)
				.selectAs(DictionaryProjectDO::getSimpleName, MaterialAssayStandardForecastProjectExtendRespVO::getSimpleName)
				.selectAs(DictionaryProjectDO::getShowName, MaterialAssayStandardForecastProjectExtendRespVO::getShowName)
				.eqIfPresent(MaterialAssayStandardDO::getBaseSampleId, reqVO.getBaseSampleId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getMaterialAssayStandardId, reqVO.getMaterialAssayStandardId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDictionaryProjectId, reqVO.getDictionaryProjectId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDictionaryProjectCode, reqVO.getDictionaryProjectCode())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getUnitId, reqVO.getUnitId())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getUnit, reqVO.getUnit())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDataType, reqVO.getDataType())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getDecimalPosition, reqVO.getDecimalPosition())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getIsDefault, reqVO.getIsDefault())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(MaterialAssayStandardForecastProjectDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(MaterialAssayStandardForecastProjectDO::getRemark, reqVO.getRemark())
                .orderByDesc(MaterialAssayStandardForecastProjectDO::getId));
    }

}