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

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

/**
 * 机器代理Mapper接口
 */
@Mapper
public interface MachineProxyMapper extends BaseMapperX<MachineProxyDO> {

    default PageResult<MachineProxyDO> selectPage(MachineProxyVO machineProxyVO) {
        LambdaQueryWrapperX<MachineProxyDO> machineProxyDOLambdaQueryWrapperX = new LambdaQueryWrapperX<MachineProxyDO>()
            .eqIfPresent(MachineProxyDO::getHostIp, machineProxyVO.getHostIp())
            .likeIfPresent(MachineProxyDO::getDescription, machineProxyVO.getDescription());
        if (machineProxyVO.getStatus() != -1) {
            machineProxyDOLambdaQueryWrapperX.eqIfPresent(MachineProxyDO::getStatus, machineProxyVO.getStatus());
        }
        if (machineProxyVO.getProxyType() != -1) {
            machineProxyDOLambdaQueryWrapperX.eqIfPresent(MachineProxyDO::getProxyType, machineProxyVO.getProxyType());
        }
        return selectPage(machineProxyVO, machineProxyDOLambdaQueryWrapperX);
    }

}
