import { defHttp } from '/@/utils/http/axios';
import { setParams } from '/@/utils/index';
enum Api {
  genBatchGenCode = '/gen/batchGenCode',
  genBatchGenCodeTableNames = '/gen/batchGenCode',
  genColumn = '/gen/column',
  genColumnTableId = '/gen/column',
  genDbList = '/gen/db/list',
  genDownload = '/gen/download',
  genDownloadTableName = '/gen/download',
  genEdit = '/gen/edit',
  genEditDetial = '/gen/edit/detial',
  genGenCode = '/gen/genCode',
  genGenCodeTableName = '/gen/genCode',
  genImportTable = '/gen/importTable',
  genList = '/gen/list',
  genPreview = '/gen/preview',
  genPreviewTableId = '/gen/preview',
  genRemove = '/gen/remove',
  genSynchDb = '/gen/synchDb',
}

/**
 * @description: 批量生成代码
 * @method: GET
 */
export const genBatchGenCode = (params?: object) => {
  return defHttp.get({ url: Api.genBatchGenCode, params: params });
};
/**
 * @description: 批量生成代码
 * @method: GET
 */
export const genBatchGenCodeTableNames = (tableNames?: string | number, params?: object) => {
  return defHttp.get({ url: Api.genBatchGenCodeTableNames + '/' + tableNames, params: params });
};
/**
 * @description: 查询数据表字段列表,权限:tool:gen:list
 * @method: GET
 */
export const genColumn = (params?: object) => {
  return defHttp.get({ url: Api.genColumn, params: params });
};
/**
 * @description: 查询数据表字段列表,权限:tool:gen:list
 * @method: GET
 */
export const genColumnTableId = (tableId?: string | number, params?: object) => {
  return defHttp.get({ url: Api.genColumnTableId + '/' + tableId, params: params });
};
/**
 * @description: 查询未导入表列表,权限:tool:gen:list
 * @method: POST
 */
export const genDbList = (params?: object) => {
  return defHttp.post({ url: Api.genDbList, params: setParams(params) });
};
/**
 * @description: 生成代码（下载方式）
 * @method: GET
 */
export const genDownload = (params?: object) => {
  return defHttp.get({ url: Api.genDownload, params: params });
};
/**
 * @description: 生成代码（下载方式）
 * @method: GET
 */
export const genDownloadTableName = (tableName?: string | number, params?: object) => {
  return defHttp.get({ url: Api.genDownloadTableName + '/' + tableName, params: params });
};
/**
 * @description: 修改保存代码生成逻辑,权限:tool:gen:edit
 * @method: POST
 */
export const genEdit = (params?: object) => {
  return defHttp.post({ url: Api.genEdit, params: params });
};
/**
 * @description: 获取修改代码生成配置,权限:tool:gen:edit
 * @method: POST
 */
export const genEditDetial = (params?: object) => {
  return defHttp.post({ url: Api.genEditDetial, params: params });
};
/**
 * @description: 生成代码（自定义路径）
 * @method: GET
 */
export const genGenCode = (params?: object) => {
  return defHttp.get({ url: Api.genGenCode, params: params });
};
/**
 * @description: 生成代码（自定义路径）
 * @method: GET
 */
export const genGenCodeTableName = (tableName?: string | number, params?: object) => {
  return defHttp.get({ url: Api.genGenCodeTableName + '/' + tableName, params: params });
};
/**
 * @description: 导入表结构,权限:tool:gen:add
 * @method: POST
 */
export const genImportTable = (params?: object) => {
  return defHttp.post({ url: Api.genImportTable, params: params });
};
/**
 * @description: 查询代码生成列表,权限:tool:gen:list
 * @method: POST
 */
export const genList = (params?: object) => {
  return defHttp.post({ url: Api.genList, params: setParams(params) });
};
/**
 * @description: 预览代码
 * @method: GET
 */
export const genPreview = (params?: object) => {
  return defHttp.get({ url: Api.genPreview, params: params });
};
/**
 * @description: 预览代码
 * @method: GET
 */
export const genPreviewTableId = (tableId?: string | number, params?: object) => {
  return defHttp.get({ url: Api.genPreviewTableId + '/' + tableId, params: params });
};
/**
 * @description: 删除代码生成,权限:tool:gen:remove
 * @method: POST
 */
export const genRemove = (params?: object) => {
  return defHttp.post({ url: Api.genRemove, params: params });
};
/**
 * @description: 同步数据库
 * @method: POST
 */
export const genSynchDb = (params?: object) => {
  return defHttp.post({ url: Api.genSynchDb, params: params });
};
