import { http } from '@/utils/http/axios';
import {
  LoginLogPageRequest,
  LoginLogResponse,
  OperationLogResponse,
  OperationLogPageRequest,
  SystemLogRequest,
  SystemLogResponse,
  SystemExport,
  OperationPageDetail,
  OperationExport,
} from '@/types/log/type';

/**
 *@description: V4: 获取登录日志列表
 */
export function queryLoginLogList(data: LoginLogPageRequest) {
  return http.request<LoginLogResponse>({
    url: '/admin/log/queryLoginLogPage',
    method: 'post',
    data: data,
  });
}

/**
 * @description: @v4：登录日志导出 admin/log/exportLoginLog
 */
export function exportLoginLog(data: LoginLogPageRequest) {
  return http.request(
    {
      url: '/admin/log/exportLoginLog',
      method: 'post',
      responseType: 'blob',
      data,
    },
    { isTransformResponse: false },
  );
}

/**
 *@description: V4: 获取操作日志列表
 */
export function queryOperationLogList(data: OperationLogPageRequest) {
  return http.request<OperationLogResponse>({
    url: '/admin/log/queryLogPage',
    method: 'post',
    data: data,
  });
}

/**
 * @description: @v4：操作日志导出 admin/log/exportLog
 */
export function exportOperationLog(data: OperationExport) {
  return http.request(
    {
      url: '/admin/log/exportLog',
      method: 'post',
      responseType: 'blob',
      data,
    },
    { isTransformResponse: false },
  );
}

/**
 *@description: V4: 获取操作日志详情
 */
export function queryOperationLogDetail(id: number) {
  return http.request<OperationPageDetail>({
    url: `/admin/log/queryLogDetail?id=${id}`,
    method: 'get',
  });
}

/**
 *@description: V4: 获取系统日志列表
 */
export function querySystemLogList(data: SystemLogRequest) {
  return http.request<SystemLogResponse>({
    url: '/admin/log/queryEventLogPage',
    method: 'post',
    data: data,
  });
}

/**
 * @description: @v4：系统日志导出 admin/log/exportEventLog
 */
export function exportSystemLog(data: SystemExport) {
  return http.request(
    {
      url: '/admin/log/exportEventLog',
      method: 'post',
      responseType: 'blob',
      data,
    },
    { isTransformResponse: false },
  );
}
