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

/**
 * 荧光分析线 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ConfigXRFLineMapper extends BaseMapperX<ConfigXRFLineDO> {

    default PageResult<ConfigXRFLineDO> selectPage(ConfigXRFLinePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConfigXRFLineDO>()
                .eqIfPresent(ConfigXRFLineDO::getDeviceNo, reqVO.getDeviceNo())
                .likeIfPresent(ConfigXRFLineDO::getLineName, reqVO.getLineName())
                .eqIfPresent(ConfigXRFLineDO::getIsUse, reqVO.getIsUse())
                .eqIfPresent(ConfigXRFLineDO::getConnectString, reqVO.getConnectString())
                .eqIfPresent(ConfigXRFLineDO::getDataSourceType, reqVO.getDataSourceType())
                .betweenIfPresent(ConfigXRFLineDO::getLastSynchronousDataTime, reqVO.getLastSynchronousDataTime())
                .betweenIfPresent(ConfigXRFLineDO::getLastCheckDataTime, reqVO.getLastCheckDataTime())
                .eqIfPresent(ConfigXRFLineDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(ConfigXRFLineDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ConfigXRFLineDO::getRemark, reqVO.getRemark())
                .orderByDesc(ConfigXRFLineDO::getId));
    }

	default List<ConfigXRFLineDO> selectByDeviceNo(String deviceNo) {
		return selectList(new LambdaQueryWrapperX<ConfigXRFLineDO>()
				.eq(ConfigXRFLineDO::getDeviceNo, deviceNo)
				.eq(ConfigXRFLineDO::getIsUse, QmsCommonConstant.YES));
	}

	default ConfigXRFLineDO selectByDeviceNoAndLineName(String deviceNo, String lineName) {
		return selectOne(new LambdaQueryWrapperX<ConfigXRFLineDO>()
				.eq(ConfigXRFLineDO::getDeviceNo, deviceNo)
				.eq(ConfigXRFLineDO::getLineName, lineName)
				.eq(ConfigXRFLineDO::getIsUse, QmsCommonConstant.YES));
	}

}