package com.gyee.frame.service.health;

import com.gyee.frame.common.exception.QiNiuException;
import com.gyee.frame.common.exception.enums.QiNiuErrorEnum;
import com.gyee.frame.mapper.auto.MetricsMapper;
import com.gyee.frame.model.auto.Metrics;
import com.gyee.frame.model.auto.MetricsExample;
import org.springframework.stereotype.Service;

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

@Service
public class MetricsService {

    @Resource
    private MetricsMapper metricsMapper;

    /**
     * 通过MetricsId查询
     * @param metricId
     * @return
     */
    public List<Metrics> getMetricsByMetricsId(String metricId){
        MetricsExample example = new MetricsExample();

        List<Metrics> list;
        try{
            example.createCriteria().andMetricidEqualTo(metricId);
            list = metricsMapper.selectByExample(example);
        }catch (Exception e){
            throw new QiNiuException(QiNiuErrorEnum.ERROR_DATA);
        }

        return list;
    }
}
