import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AlertQuery, AlertVO, AlertHandleForm } from './types';

// 查询预警列表
export function listAlert(query: AlertQuery): AxiosPromise<AlertVO[]> {
  return request({ url: '/edu/alert/list', method: 'get', params: query });
}

// 预警统计
export function alertStats(): AxiosPromise<Record<string, number>> {
  return request({ url: '/edu/alert/stats', method: 'get' });
}

// 处理预警
export function handleAlert(data: AlertHandleForm) {
  return request({ url: '/edu/alert/handle', method: 'put', data });
}

// 忽略预警
export function ignoreAlert(data: AlertHandleForm) {
  return request({ url: '/edu/alert/ignore', method: 'put', data });
}

// 删除预警
export function delAlert(ids: string | number | (string | number)[]) {
  return request({ url: '/edu/alert/' + ids, method: 'delete' });
}

// 手动触发全量扫描
export function scanAlert(): AxiosPromise<number> {
  return request({ url: '/edu/alert/scan', method: 'post' });
}
