package xtools.boot.db.mybatis.monitor;

import com.alibaba.fastjson2.JSONObject;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import xtools.boot.api.exection.BizError;
import xtools.boot.db.mybatis.enums.MySqlMonitorEnums;
import xtools.boot.db.mybatis.mapper.MonitorDatabasesMapper;

import java.util.List;
import java.util.Objects;

/**
 * <p>Title : MySqlMonitor</p>
 * <p>Description : MySqlMonitor</p>
 * <p>DevelopTools : Idea_x64_v2026.1</p>
 * <p>DevelopSystem : macOS Sequoia 15.7.5</p>
 * <p>Company : org.xujun</p>
 *
 * @author : XuJun
 * @version : 5.0.0
 * @date : 2026/2/14 16:18
 */
@Component
@RequiredArgsConstructor
public class MySqlMonitor {

    private final MonitorDatabasesMapper monitorDatabasesMapper;

    /**
     * 获取MySQL监控信息
     *
     * @param type 枚举
     * @return MySQL监控信息
     */
    public List<JSONObject> info(MySqlMonitorEnums type) {
        if (Objects.isNull(type)) {
            throw new BizError("类型参数不能为空");
        }
        return monitorDatabasesMapper.mysql(type.getSql());
    }

}
