import type { Page } from './base/page';

// 表格服务接口
export interface TableService<T, P = any> {
  list: (params: P) => Promise<Page<T>>;
  create?: (data: T) => Promise<T>;
  update?: (id: number, data: T) => Promise<T>;
  delete?: (id: number) => Promise<void>;
}

// 表格配置项
export interface TableConfig<T> {
  message?: {
    createSuccess?: string;
    updateSuccess?: string;
    deleteSuccess?: string;
    loadError?: string;
  };
  defaultPageSize?: number;
  selection?: boolean;  // 是否支持选择
  onDataChange?: (data: T[]) => void;  // 数据变化回调
}

// 表格状态
export interface TableState<T> {
  list: T[];
  pagination: {
    current: number;
    pageSize: number;
    total: number;
  };
  loading: boolean;
  selectedRows?: T[];
  selectedRowKeys?: React.Key[];
}

// Hook参数
export interface UseTableDataProps<T, P = any> {
  service: TableService<T, P>;
  defaultParams?: Partial<P>;
  config?: TableConfig<T>;
} 