/**
 * ERP动态API配置类型定义
 */

export interface ErpApiConfig {
  apiId: number;
  apiName: string;
  apiPath: string;
  apiMethod: string;
  apiDesc?: string;
  apiVersion: string;

  // 数据源配置
  dataSource: string;

  // SQL配置
  sqlTemplate: string;
  resultType: string;

  // 分页配置
  supportPagination: number;
  pageParamName?: string;
  sizeParamName?: string;

  // 权限配置
  requireAuth: number;
  permissionCode?: string;

  // 缓存配置
  enableCache: number;
  cacheKeyTemplate?: string;
  cacheTtl?: number;

  // 来源表信息
  sourceTable?: string;
  sourceTableComment?: string;

  // 状态
  status: number;
  createTime?: string;
  updateTime?: string;
  createBy?: string;
  updateBy?: string;
  remark?: string;
}

export interface ErpApiParam {
  paramId: number;
  apiId: number;

  // 参数基本信息
  paramName: string;
  paramDesc?: string;
  paramType: string;

  // 参数位置
  paramPosition: string;

  // 参数验证
  isRequired: number;
  defaultValue?: string;

  // SQL映射
  sqlParamName?: string;

  // 排序
  sort?: number;
  createTime?: string;
  updateTime?: string;
}

export interface ApiTestResult {
  apiPath: string;
  testMethod: string;
  requestParams?: Record<string, any>;
  success: boolean;
  data?: any;
  executionTime?: number;
  executedSql?: string;
  errorMessage?: string;
  errorStack?: string;
}

export interface ApiStats {
  totalCalls: number;
  successCalls: number;
  errorCalls: number;
  avgResponseTime: number;
  maxResponseTime: number;
  minResponseTime: number;
  errorRate: number;
}

export interface ApiConfigDetail {
  info: ErpApiConfig;
  params: ErpApiParam[];
}