import service from '@/utils/request';
import type { DatabaseOperation, ApiResponse } from '@/types/global';

/**
 * 执行数据库操作
 * @param operation 数据库操作参数
 */
export const execDatabase = <T = any>(operation: DatabaseOperation): Promise<ApiResponse<T>> => {
  return service.get('', operation);
};

/**
 * 创建数据库操作数据
 * @param type 操作类型
 * @param sql SQL 语句
 * @param params 参数
 */
export const createDatabaseData = (type: string, sql: string, params: any[]): DatabaseOperation => {
  return {
    type,
    sql,
    params
  };
};
