package com.zt.plat.module.qms.business.other.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.config.controller.vo.MaterialAssayStandardDetailRespVO;
import com.zt.plat.module.qms.business.dic.dal.dataobject.DictionaryProjectDO;
import com.zt.plat.module.qms.business.other.controller.vo.*;
import com.zt.plat.module.qms.business.other.dal.dataobject.OtherDictionaryProjectDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;

/**
 * 第三方系统检测项目字典对应 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface OtherDictionaryProjectMapper extends BaseMapperX<OtherDictionaryProjectDO> {

    default PageResult<OtherDictionaryProjectDO> selectPage(OtherDictionaryProjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OtherDictionaryProjectDO>()
                .eqIfPresent(OtherDictionaryProjectDO::getOtherSystem, reqVO.getOtherSystem())
                .eqIfPresent(OtherDictionaryProjectDO::getDictionaryProjectId, reqVO.getDictionaryProjectId())
                .eqIfPresent(OtherDictionaryProjectDO::getOtherId, reqVO.getOtherId())
                .eqIfPresent(OtherDictionaryProjectDO::getOtherCode, reqVO.getOtherCode())
                .likeIfPresent(OtherDictionaryProjectDO::getOtherName, reqVO.getOtherName())
                .likeIfPresent(OtherDictionaryProjectDO::getOtherSimpleName, reqVO.getOtherSimpleName())
                .likeIfPresent(OtherDictionaryProjectDO::getOtherShowName, reqVO.getOtherShowName())
                .eqIfPresent(OtherDictionaryProjectDO::getOtherKey, reqVO.getOtherKey())
                .eqIfPresent(OtherDictionaryProjectDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(OtherDictionaryProjectDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OtherDictionaryProjectDO::getRemark, reqVO.getRemark())
                .orderByDesc(OtherDictionaryProjectDO::getId));
    }

	default List<OtherDictionaryProjectDO> selectByOtherSystemAndOtherIds(String otherSystem, List<String> otherIdList) {
		return selectList(new LambdaQueryWrapperX<OtherDictionaryProjectDO>()
				.eq(OtherDictionaryProjectDO::getOtherSystem, otherSystem)
				.in(OtherDictionaryProjectDO::getOtherId, otherIdList));
	}
	
	default List<OtherDictionaryProjectExtendRespVO> selectExtendByOtherSystemAndOtherIds(String otherSystem, List<String> otherIdList) {
		return selectJoinList(OtherDictionaryProjectExtendRespVO.class, new MPJLambdaWrapperX<OtherDictionaryProjectDO>()
				.leftJoin(DictionaryProjectDO.class, DictionaryProjectDO::getId, OtherDictionaryProjectDO::getDictionaryProjectId)
				.selectAll(OtherDictionaryProjectDO.class)
    			.selectAs(DictionaryProjectDO::getName, OtherDictionaryProjectExtendRespVO::getDictionaryProjectName)
    			.selectAs(DictionaryProjectDO::getSimpleName, OtherDictionaryProjectExtendRespVO::getDictionaryProjectSimpleName)
    			.selectAs(DictionaryProjectDO::getShowName, OtherDictionaryProjectExtendRespVO::getDictionaryProjectShowName)
				.eq(OtherDictionaryProjectDO::getOtherSystem, otherSystem)
				.in(OtherDictionaryProjectDO::getOtherId, otherIdList));
	}

}