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 TODO
 * @Description TODO
 * @Author liukaixiong
 * @Date 2020/12/14 11:01
 */
//@Component
public class MaxSlowUrlTopReportInvoke implements TopSlowTimeListReport<SlowGroupModel> {
    int minRequestTime = 3000;
    int 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.selectByUrlRequestTimeGroupList(reportDate, 3000, 10);
        return slowGroupModels;
    }
}
