package com.unis.crk.hardware.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.unis.crk.hardware.entity.Hardwareloadometer;
import com.unis.crk.hardware.entity.Unithardware;
import com.unis.crk.hardware.mapper.HardwareloadometerMapper;
import com.unis.crk.hardware.service.IHardwareloadometerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ghh
 * @since 2021-09-15
 */
@Service
public class HardwareloadometerServiceImpl extends ServiceImpl<HardwareloadometerMapper, Hardwareloadometer> implements IHardwareloadometerService {
    @Resource
    private HardwareloadometerMapper hardwareloadometerMapper;
    @Override
    public List<Hardwareloadometer> getHardwareloadometerByUI(String UnitId,String filterIp,String isenable) {
        QueryWrapper<Hardwareloadometer> basicEnumQueryWrapper = new QueryWrapper<>();
        basicEnumQueryWrapper.eq("unitId",UnitId);
        if(!StringUtils.isEmpty(filterIp)){
            basicEnumQueryWrapper.eq("FILTER_IP",filterIp);
        }

        if(!StringUtils.isEmpty(isenable)){
            basicEnumQueryWrapper.eq("isenable",isenable);
        }
        List<Hardwareloadometer> hardwareloadometers = hardwareloadometerMapper.selectList(basicEnumQueryWrapper);
        return hardwareloadometers;
    }

    @Override
    public List<Hardwareloadometer> getAllByUnitId(String unitId) {
        QueryWrapper<Hardwareloadometer> basicEnumQueryWrapper = new QueryWrapper<>();
        basicEnumQueryWrapper.eq("unitId",unitId);

        List<Hardwareloadometer> hardwareloadometers = hardwareloadometerMapper.selectList(basicEnumQueryWrapper);
        return hardwareloadometers;
    }

    @Override
    public IPage<Hardwareloadometer> getHardwaredLoadometer(Page<Hardwareloadometer> objectPage, QueryWrapper<Hardwareloadometer> hardwareloadometerQueryWrapper) {
        return hardwareloadometerMapper.selectPage(objectPage,hardwareloadometerQueryWrapper);
    }
}
