/**
 * KRA - Export Template Service
 * Export template management APIs
 */
import { request } from '@umijs/max';

// Create export template
export async function createSysExportTemplate(data: any) {
  return request<any>('/sysExportTemplate/createSysExportTemplate', {
    method: 'POST',
    data,
  });
}

// Delete export template
export async function deleteSysExportTemplate(data: { ID: number }) {
  return request<any>('/sysExportTemplate/deleteSysExportTemplate', {
    method: 'DELETE',
    data,
  });
}

// Batch delete export templates
export async function deleteSysExportTemplateByIds(data: { ids: number[] }) {
  return request<any>('/sysExportTemplate/deleteSysExportTemplateByIds', {
    method: 'DELETE',
    data,
  });
}

// Update export template
export async function updateSysExportTemplate(data: any) {
  return request<any>('/sysExportTemplate/updateSysExportTemplate', {
    method: 'PUT',
    data,
  });
}

// Find export template by ID
export async function findSysExportTemplate(params: { ID: number }) {
  return request<any>('/sysExportTemplate/findSysExportTemplate', {
    method: 'GET',
    params,
  });
}

// Get export template list
export async function getSysExportTemplateList(params: {
  page: number;
  pageSize: number;
  name?: string;
  tableName?: string;
  templateID?: string;
}) {
  return request<any>('/sysExportTemplate/getSysExportTemplateList', {
    method: 'GET',
    params,
  });
}

// Export excel with token
export async function exportExcel(params: { templateID: string; [key: string]: any }) {
  return request<any>('/sysExportTemplate/exportExcel', {
    method: 'GET',
    params,
  });
}

// Export template
export async function exportTemplate(params: { templateID: string }) {
  return request<any>('/sysExportTemplate/exportTemplate', {
    method: 'GET',
    params,
  });
}

// Preview SQL
export async function previewSQL(params: { templateID: string; params?: string }) {
  return request<any>('/sysExportTemplate/previewSQL', {
    method: 'GET',
    params,
  });
}
