import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { RequestRecord, RequestRecordParam } from './model';

/**
 * 分页查询请求日志
 */
export async function pageRequestRecords(params: RequestRecordParam) {
  const res = await request.get<ApiResult<PageResult<RequestRecord>>>(
    '/system/request-record/page',
    { params }
  );
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 获取请求日志详情
 */
export async function getRequestRecordInfo(id: number) {
  const res = await request.get<ApiResult<RequestRecord>>(
    '/system/request-record/info?id=' + id
  );
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

