export interface ApiResponse<T> {
  code: number;
  message: string;
  data: T;
}

export interface AdminProfile {
  id: number;
  username: string;
  name: string;
  status: number;
}

export interface DashboardStats {
  userCount: number;
  sessionCount: number;
  messageCount: number;
  aiRequestCount: number;
  knowledgeCount: number;
}

export interface AdminUser {
  id: number;
  phone: string;
  name: string;
  status: number;
  dailyChatLimit: number;
  dailyChatUsed: number;
  expiredAt?: string | null;
  lastLoginAt?: string | null;
}

export interface KnowledgeItem {
  id: number;
  name: string;
  feishuSpaceId: string;
  feishuNodeId: string;
  status: number;
  remark?: string | null;
}

export interface ModelItem {
  id: number;
  provider: string;
  displayName?: string | null;
  apiType: string;
  modelName: string;
  baseUrl?: string | null;
  apiUrl: string;
  apiKeyMasked: string;
  authType: string;
  apiVersion?: string | null;
  temperature?: number | null;
  topP?: number | null;
  topK?: number | null;
  presencePenalty?: number | null;
  frequencyPenalty?: number | null;
  maxToken?: number | null;
  contextWindow?: number | null;
  streamEnabled: number;
  responseFormat?: string | null;
  extraParams?: string | null;
  remark?: string | null;
  timeoutSecond: number;
  enabled: number;
}

export interface ChatRecord {
  id: number;
  userId: number;
  userPhone: string;
  userName: string;
  title: string;
  messageCount: number;
  lastMessageAt?: string | null;
  updatedAt: string;
}

export interface ChatMessageRecord {
  id: number;
  sessionId: number;
  userId: number;
  role: "user" | "assistant";
  content: string;
  messageStatus: string;
  tokenInput?: number | null;
  tokenOutput?: number | null;
  responseTimeMs?: number | null;
  modelId?: number | null;
  createdAt: string;
}

export interface AiLogRecord {
  id: number;
  sessionId?: number | null;
  messageId?: number | null;
  userId?: number | null;
  modelName?: string | null;
  knowledgeIds?: string | null;
  retrieveCount: number;
  inputToken?: number | null;
  outputToken?: number | null;
  totalToken?: number | null;
  costMs?: number | null;
  status: string;
  errorMessage?: string | null;
  prompt?: string | null;
  createdAt: string;
}

export interface ChatDetail {
  session: ChatRecord;
  messages: ChatMessageRecord[];
  aiLogs: AiLogRecord[];
}

export interface ChatRecordQuery {
  keyword?: string;
  userId?: number | null;
  status?: string;
  dateFrom?: string;
  dateTo?: string;
}
