package cd.casic.module.machine.dal.mysql;

import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
import cd.casic.module.machine.controller.vo.MachineEnvVO;
import cd.casic.module.machine.dal.dataobject.MachineEnvDO;
import cd.casic.framework.commons.pojo.PageResult;
import cd.casic.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

import java.time.LocalDateTime;

/**
 * 环境变量Mapper接口
 */
@Mapper
public interface MachineEnvMapper extends BaseMapperX<MachineEnvDO> {
    default PageResult<MachineEnvDO> selectPage(MachineEnvVO machineEnvVO) {
        LambdaQueryWrapperX<MachineEnvDO> machineEnvDOLambdaQueryWrapperX = new LambdaQueryWrapperX<MachineEnvDO>()
            .likeIfPresent(MachineEnvDO::getEnvKey, machineEnvVO.getEnvKey())
            .likeIfPresent(MachineEnvDO::getDescription, machineEnvVO.getDescription());
        if (machineEnvVO.getMachineId() != null && machineEnvVO.getMachineId() > 0) {
            machineEnvDOLambdaQueryWrapperX.eqIfPresent(MachineEnvDO::getMachineId, machineEnvVO.getMachineId());
        }
        return selectPage(machineEnvVO, machineEnvDOLambdaQueryWrapperX);
    }

}
