import { defHttp } from '/@/utils/http/axios';
import { setParams } from '/@/utils/index';
enum Api {
  genBasicPage = '/gen/basic/page',
  genBasicAdd = '/gen/basic/add',
  genBasicDelete = '/gen/basic/delete',
  genBasicDetail = '/gen/basic/detail',
  genBasicEdit = '/gen/basic/edit',
  genBasicExecGenPro = '/gen/basic/execGenPro',
  genBasicExecGenZip = '/gen/basic/execGenZip',
  genBasicPreview = '/gen/basic/previewGen',
  genBasicTableColumns = '/gen/basic/tableColumns',
  genBasicTables = '/gen/basic/tables',

  genConfigList = '/gen/config/list',
  genConfigEditBatch = '/gen/config/editBatch',
  genConfigDelete = '/gen/config/delete',
  genConfigDetail = '/gen/config/detail',
  genConfigEdit = '/gen/config/edit',
}

/**
 *
 * @param params
 * @returns
 */
export const genBasicPage = (params?: object) => {
  return defHttp.post({ url: Api.genBasicPage, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicAdd = (params?: object) => {
  return defHttp.post({ url: Api.genBasicAdd, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicSubmitForm = (params?: object, edit = false) => {
  return defHttp.post({
    url: edit ? Api.genBasicAdd : Api.genBasicEdit,
    params: setParams(params),
  });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicDelete = (params?: object) => {
  return defHttp.post({ url: Api.genBasicDelete, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicDetail = (params?: object) => {
  return defHttp.get({ url: Api.genBasicDetail, params: params });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicEdit = (params?: object) => {
  return defHttp.post({ url: Api.genBasicEdit, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicExecGenPro = (params?: object) => {
  return defHttp.post({ url: Api.genBasicExecGenPro, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicExecGenZip = (params?: object) => {
  return defHttp.get({
    url: Api.genBasicExecGenZip,
    params: params,
    responseType: 'blob',
  });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicPreview = (params?: object) => {
  return defHttp.get({ url: Api.genBasicPreview, params: params });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicTableColumns = (params?: object) => {
  return defHttp.get({ url: Api.genBasicTableColumns, params: params });
};

/**
 *
 * @param params
 * @returns
 */
export const genBasicTables = (params?: object) => {
  return defHttp.get({ url: Api.genBasicTables, params: params });
};

/**
 *
 * @param params
 * @returns
 */
export const genConfigList = (params?: object) => {
  return defHttp.get({ url: Api.genConfigList, params: params });
};

/**
 *
 * @param params
 * @returns
 */
export const genConfigDelete = (params?: object) => {
  return defHttp.post({ url: Api.genBasicDelete, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genConfigDetail = (id: string) => {
  return defHttp.get({ url: Api.genConfigDetail + '/' + id });
};

/**
 *
 * @param params
 * @returns
 */
export const genConfigEdit = (params?: object) => {
  return defHttp.post({ url: Api.genConfigEdit, params: setParams(params) });
};

/**
 *
 * @param params
 * @returns
 */
export const genConfigEditBatch = (params?: object) => {
  return defHttp.post({ url: Api.genConfigEditBatch, params: setParams(params) });
};
