// 系统监控类型定义

// 登录日志
export interface LoginLog {
  id: string;
  userId: string;
  username: string;
  loginTime: string;
  ipAddress: string;
  device: string;
  browser?: string;
  os?: string;
  location?: string;
  status: 'success' | 'failed';
  failReason?: string;
  sessionId?: string;
}

// 操作日志
export interface OperationLog {
  id: string;
  userId: string;
  username: string;
  operationTime: string;
  module: string;
  action: string;
  description: string;
  ipAddress: string;
  requestUrl?: string;
  requestMethod?: string;
  requestParams?: string;
  responseData?: string;
  duration?: number; // 毫秒
  status: 'success' | 'failed';
  errorMessage?: string;
}

export type OperationModule =
  | 'user'
  | 'role'
  | 'permission'
  | 'machinery'
  | 'driver'
  | 'task'
  | 'system'
  | 'other';

export type OperationAction =
  | 'create'
  | 'update'
  | 'delete'
  | 'view'
  | 'export'
  | 'import'
  | 'login'
  | 'logout';

// 性能监控
export interface SystemPerformance {
  timestamp: string;
  cpu: {
    usage: number; // 百分比
    cores: number;
  };
  memory: {
    total: number; // MB
    used: number; // MB
    free: number; // MB
    usage: number; // 百分比
  };
  disk: {
    total: number; // GB
    used: number; // GB
    free: number; // GB
    usage: number; // 百分比
  };
  jvm?: {
    heapUsed: number; // MB
    heapMax: number; // MB
    heapUsage: number; // 百分比
    nonHeapUsed: number; // MB
    threadCount: number;
    gcCount: number;
    gcTime: number; // 毫秒
  };
  tomcat?: {
    threadCount: number;
    maxThreads: number;
    connectionCount: number;
    requestCount: number;
    errorCount: number;
  };
}

// 网络日志
export interface NetworkLog {
  id: string;
  timestamp: string;
  method: string;
  url: string;
  requestHeaders?: Record<string, string>;
  requestParams?: string;
  requestBody?: string;
  responseStatus: number;
  responseTime: number; // 毫秒
  responseBody?: string;
  responseSize?: number; // bytes
  clientIp?: string;
  userAgent?: string;
  userId?: string;
  username?: string;
}