/**
 * KRA - API Response Type Definitions
 */

// Standard API response wrapper
export interface ApiResponse<T = any> {
  code: number;
  data: T;
  msg: string;
}

// Pagination params
export interface PageParams {
  page: number;
  pageSize: number;
  orderKey?: string;
  desc?: boolean;
}

// Pagination result
export interface PageResult<T> {
  list: T[];
  total: number;
  page: number;
  pageSize: number;
}

// Login related
export interface LoginParams {
  username: string;
  password: string;
  captcha: string;
  captchaId: string;
}

export interface LoginResult {
  user: import('./index').UserInfo;
  token: string;
  expiresAt: number;
}

export interface CaptchaResult {
  captchaId: string;
  picPath: string;
  captchaLength: number;
  openCaptcha: boolean;
}

// User related
export interface ChangePasswordParams {
  password: string;
  newPassword: string;
}

export interface SetUserAuthoritiesParams {
  ID: number;
  authorityIds: number[];
}

// Menu related
export interface MenuAuthorityParams {
  authorityId: number;
  menus: import('./index').MenuItem[];
}

export interface GetMenuAuthorityResult {
  menus: import('./index').MenuItem[];
}

// Authority related
export interface CreateAuthorityParams {
  authorityId: number;
  authorityName: string;
  parentId: number;
}

export interface SetDataAuthorityParams {
  authorityId: number;
  dataAuthorityId: { authorityId: number }[];
}

// Casbin related
export interface CasbinInfo {
  path: string;
  method: string;
}

export interface UpdateCasbinParams {
  authorityId: number;
  casbinInfos: CasbinInfo[];
}

// File upload related
export interface UploadParams {
  file: File;
}

export interface ChunkUploadParams {
  file: File;
  chunkNumber: number;
  chunkSize: number;
  currentChunkSize: number;
  totalChunks: number;
  totalSize: number;
  identifier: string;
  filename: string;
}

// Export template related
export interface ExportTemplate {
  ID: number;
  name: string;
  templateId: string;
  templateInfo: string;
  limit: number;
  order: string;
  conditions: string;
}

// Auto code related - 详细类型定义请参考 @/services/kratos/autoCode.ts
export type { 
  AutoCodeField, 
  AutoCodeParams,
  DataSource,
  CustomMethod,
  CustomMethodParam,
  CustomCondition,
  FieldSearchType,
  FieldIndexType,
  DatabaseInfo,
  TableInfo,
  ColumnInfo,
  AutoCodeHistory,
  AutoCodePackage,
  AddFuncParams,
  LLMAutoParams,
  EyeParams,
  MCPParams,
  MCPTool,
  RollbackParams,
  PreviewResult,
} from '@/services/kratos/autoCode';

// System error related
export interface SysError {
  ID: number;
  CreatedAt: string;
  error: string;
  stack: string;
  method: string;
  path: string;
}

// Announcement related
export interface Announcement {
  ID: number;
  CreatedAt: string;
  UpdatedAt: string;
  title: string;
  content: string;
  type: number;
  status: number;
}
