70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
// @ts-ignore
|
|
/* eslint-disable */
|
|
import request from '@/utils/request';
|
|
|
|
/** 创建服务商副本 POST /ServiceProvider/Copy */
|
|
export async function postServiceProviderCopy(
|
|
body: API.ServiceProviderInput,
|
|
options?: { [key: string]: any }
|
|
) {
|
|
return request<boolean>(`api/ServiceProvider/Copy`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json-patch+json',
|
|
},
|
|
data: body,
|
|
...(options || {}),
|
|
});
|
|
}
|
|
|
|
/** 导出服务商数据 POST /ServiceProvider/Export */
|
|
export async function postServiceProviderExport(
|
|
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
|
|
params: API.postServiceProviderExportParams,
|
|
options?: { [key: string]: any }
|
|
) {
|
|
return request<any>(`api/ServiceProvider/Export`, {
|
|
method: 'POST',
|
|
params: {
|
|
...params,
|
|
},
|
|
...(options || {}),
|
|
});
|
|
}
|
|
|
|
/** 导入服务商数据 POST /ServiceProvider/Import */
|
|
export async function postServiceProviderImport(
|
|
body: {},
|
|
file?: File,
|
|
options?: { [key: string]: any }
|
|
) {
|
|
const formData = new FormData();
|
|
|
|
if (file) {
|
|
formData.append('file', file);
|
|
}
|
|
|
|
Object.keys(body).forEach((ele) => {
|
|
const item = (body as any)[ele];
|
|
|
|
if (item !== undefined && item !== null) {
|
|
if (typeof item === 'object' && !(item instanceof File)) {
|
|
if (item instanceof Array) {
|
|
item.forEach((f) => formData.append(ele, f || ''));
|
|
} else {
|
|
formData.append(ele, JSON.stringify(item));
|
|
}
|
|
} else {
|
|
formData.append(ele, item);
|
|
}
|
|
}
|
|
});
|
|
|
|
return request<boolean>(`api/ServiceProvider/Import`, {
|
|
method: 'POST',
|
|
data: formData,
|
|
requestType: 'form',
|
|
...(options || {}),
|
|
});
|
|
}
|