/**
 * KRA - System Error Service
 * System error log APIs
 */
import request from '@/utils/request';

export interface SysError {
  ID?: number;
  CreatedAt?: string;
  UpdatedAt?: string;
  form?: string;
  level?: string;
  status?: string;
  info?: string;
  solution?: string;
}

// 创建错误日志
export async function createSysError(data: SysError) {
  return request.post('/sysError/createSysError', data);
}

// 删除错误日志
export async function deleteSysError(params: { ID: number }) {
  return request.delete('/sysError/deleteSysError', { params });
}

// 批量删除错误日志
export async function deleteSysErrorByIds(params: { IDs: number[] }) {
  return request.delete('/sysError/deleteSysErrorByIds', { params });
}

// 更新错误日志
export async function updateSysError(data: SysError) {
  return request.put('/sysError/updateSysError', data);
}

// 用id查询错误日志
export async function findSysError(params: { ID: number }) {
  return request.get('/sysError/findSysError', { params });
}

// 分页获取错误日志列表
export async function getSysErrorList(params: {
  page: number;
  pageSize: number;
  form?: string;
  info?: string;
  startCreatedAt?: string;
  endCreatedAt?: string;
}) {
  return request.get('/sysError/getSysErrorList', { params });
}

// 不需要鉴权的错误日志接口
export async function getSysErrorPublic() {
  return request.get('/sysError/getSysErrorPublic');
}

// 触发错误处理（异步）- 获取AI解决方案
export async function getSysErrorSolution(params: { id: number }) {
  return request.get('/sysError/getSysErrorSolution', { params });
}

// 别名导出，兼容页面调用
export const getSysErrorById = findSysError;
