package com.zt.plat.module.qms.resource.device.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.mapper.BaseMapperX;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceConfigFlowDO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceConfigFlowPageReqVO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 设备通用流程配置 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface DeviceConfigFlowMapper extends BaseMapperX<DeviceConfigFlowDO> {

    default PageResult<DeviceConfigFlowDO> selectPage(DeviceConfigFlowPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceConfigFlowDO>()
                .eqIfPresent(DeviceConfigFlowDO::getBusinessType, reqVO.getBusinessType())
                .likeIfPresent(DeviceConfigFlowDO::getBusinessName, reqVO.getBusinessName())
                .eqIfPresent(DeviceConfigFlowDO::getFlowKey, reqVO.getFlowKey())
                .eqIfPresent(DeviceConfigFlowDO::getDataCollectionKey, reqVO.getDataCollectionKey())
                .eqIfPresent(DeviceConfigFlowDO::getTemplateKey, reqVO.getTemplateKey())
                .eqIfPresent(DeviceConfigFlowDO::getFormComponent, reqVO.getFormComponent())
                .eqIfPresent(DeviceConfigFlowDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(DeviceConfigFlowDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DeviceConfigFlowDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(DeviceConfigFlowDO::getOrderNo));
    }

    default List<DeviceConfigFlowDO> selectList(DeviceConfigFlowPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DeviceConfigFlowDO>()
                .eqIfPresent(DeviceConfigFlowDO::getBusinessType, reqVO.getBusinessType())
                .likeIfPresent(DeviceConfigFlowDO::getBusinessName, reqVO.getBusinessName())
                .eqIfPresent(DeviceConfigFlowDO::getFlowKey, reqVO.getFlowKey())
                .eqIfPresent(DeviceConfigFlowDO::getDataCollectionKey, reqVO.getDataCollectionKey())
                .eqIfPresent(DeviceConfigFlowDO::getTemplateKey, reqVO.getTemplateKey())
                .eqIfPresent(DeviceConfigFlowDO::getFormComponent, reqVO.getFormComponent())
                .eqIfPresent(DeviceConfigFlowDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(DeviceConfigFlowDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DeviceConfigFlowDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(DeviceConfigFlowDO::getOrderNo)
        );
    }

}