package com.jay.monitor.data.server.report.mysql;

import com.jay.monitor.data.server.daos.JayMonitorUrlMapperExt;
import com.jay.monitor.data.server.models.dto.report.SlowGroupModel;
import com.jay.monitor.data.server.report.TopSlowTimeListReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Module 慢请求
 * @Description 平均值过慢的情况
 * @Author liukaixiong
 * @Date 2020/12/14 11:01
 */
@Component
public class AvgSlowUrlTopReportInvoke implements TopSlowTimeListReport<SlowGroupModel> {

    private Integer minRequestTime = 1000;
    /**
     * 默认的基数值
     */
    private Integer defaultBaseCount = 10;

    private String reportName = "URL平均耗时排行  TOP 10 [超过" + minRequestTime + "毫秒,请求数量达到" + defaultBaseCount + "则纳入统计]";


    @Autowired
    private JayMonitorUrlMapperExt urlMapperExt;

    @Override
    public String reportName() {
        return reportName;
    }

    @Override
    public List<SlowGroupModel> getListData(String reportDate) {
        List<SlowGroupModel> slowGroupModels = urlMapperExt.selectByUrlAvgGroupList(reportDate, minRequestTime, defaultBaseCount);
        return slowGroupModels;
    }
}
