export interface TemplateVO extends BaseEntity {
  templateId: number | string;
  templateCode: string;
  templateName: string;
  templateType: string;
  attId: number | string;
  status: string;
  remark: string;
  // 附件信息 (从TemplateDetailVO中来)
  fileName?: string;
  originalName?: string;
  fileSuffix?: string;
  fileSize?: number;
  url?: string;
  service?: string;
}

export interface TemplateForm {
  templateId?: number | string;
  templateCode: string;
  templateName: string;
  templateType: string;
  attId?: number | string;
  status: string;
  remark?: string;
}

export interface TemplateQuery extends PageQuery {
  templateCode?: string;
  templateName?: string;
  templateType?: string;
  status?: string;
}

export interface TemplateParamVO {
  paramId: number | string;
  templateId?: number | string;
  parentId?: number | string;
  paramName: string;
  paramType: string;
  paramDesc: string;
  paramPath?: string;
  levelDepth?: number;
  sortOrder?: number;
  isRequired: string;
  isArray?: string;
  defaultValue: string;
  validationRule?: string;
  sampleData?: string;

  // 树形结构相关字段
  children?: TemplateParamVO[];
  hasChildren?: boolean;
  parentName?: string;
  parentType?: string;
  displayPath?: string;
  isLeaf?: string;

  [key: string]: any; // 添加索引签名以支持动态属性
}

export interface TemplateParamBo {
  paramId?: number | string;
  templateId: number | string;
  parentId?: number | string;
  paramName: string;
  paramType: string;
  paramDesc?: string;
  paramPath?: string;
  levelDepth?: number;
  sortOrder?: number;
  isRequired?: string;
  isArray?: string;
  defaultValue?: string;
  validationRule?: string;
  sampleData?: string;
}

// 模板详情VO（包含附件信息）
export interface TemplateDetailVO extends TemplateVO {
  fileName: string;
  originalName: string;
  fileSuffix: string;
  fileSize: number;
  url: string;
  service: string;
}

// 模板解析结果
export interface TemplateParsingResult {
  templateParams: Record<string, string>;
  tableListParams: TableListParms[];
  nestedTemplateParams: NestedTemplateParam[];
  totalParamCount: number;
  nestedParamCount: number;
  tableParamCount: number;
}

// 嵌套模板参数
export interface NestedTemplateParam {
  fullPath: string;
  rootPath: string;
  pathParts: string[];
  depth: number;
  type: string;
  variableName: string;
  description?: string;
}

// 表格列表参数
export interface TableListParms {
  tableListName: string;
  parmName: string;
  parmDes: string;
}

// 打印参数容器
export interface PrintParms {
  type: string;
  parms: any;
}

// 基础实体类型
export interface BaseEntity {
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
}

// 分页查询类型
export interface PageQuery {
  pageNum: number;
  pageSize: number;
}

// API响应类型
export interface ApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
  rows?: T[];
  total?: number;
}

// 文件上传响应
export interface UploadResponse {
  attId: number;
  fileName: string;
  originalName: string;
  fileSize: number;
  fileSuffix: string;
  url: string;
}

// 测试数据生成选项
export interface TestDataOptions {
  listItemCount?: number;
  useRealData?: boolean;
  templateType?: 'WAGE' | 'POLICY' | 'NOTICE' | 'OTHER';
}

// 参数验证结果
export interface ParamValidationResult {
  isValid: boolean;
  missingParams: string[];
  typeErrors: string[];
  providedParams: number;
  error?: string;
}

// 模板统计信息
export interface TemplateStatistics {
  totalTemplates: number;
  activeTemplates: number;
  disabledTemplates: number;
  recentUsage: number;
}

// 模板权限配置
export interface TemplatePermissions {
  canView: boolean;
  canEdit: boolean;
  canDelete: boolean;
  canPreview: boolean;
  allowedUsers: string[];
  allowedRoles: string[];
}

// 模板版本信息
export interface TemplateVersion {
  versionId: number;
  version: string;
  remark: string;
  createTime: string;
  createBy: string;
  isActive: boolean;
}

// 模板使用历史
export interface TemplateUsageHistory {
  usageId: number;
  templateId: number;
  userId: string;
  userName: string;
  operation: 'PREVIEW' | 'DOWNLOAD' | 'EDIT';
  useTime: string;
  params?: Record<string, any>;
}

// 模板对比结果
export interface TemplateCompareResult {
  template1: TemplateVO;
  template2: TemplateVO;
  paramsDiff: {
    added: TemplateParamVO[];
    removed: TemplateParamVO[];
    modified: TemplateParamVO[];
  };
  contentDiff?: string;
}
