Files
admin-vben5/apps/web-antd/src/api/system/tenant/index.ts

123 lines
2.7 KiB
TypeScript
Raw Normal View History

2024-09-23 09:47:47 +08:00
import type { Tenant } from './model';
import type { ID, IDS, PageQuery } from '#/api/common';
import { commonExport } from '#/api/helper';
2024-08-07 11:55:13 +08:00
import { requestClient } from '#/api/request';
enum Api {
2024-09-23 09:47:47 +08:00
dictSync = '/system/tenant/syncTenantDict',
2024-08-07 11:55:13 +08:00
root = '/system/tenant',
tenantDynamic = '/system/tenant/dynamic',
tenantDynamicClear = '/system/tenant/dynamic/clear',
tenantExport = '/system/tenant/export',
tenantList = '/system/tenant/list',
tenantStatus = '/system/tenant/changeStatus',
tenantSyncPackage = '/system/tenant/syncTenantPackage',
}
/**
*
* @param params
* @returns
*/
2024-09-23 09:47:47 +08:00
export function tenantList(params?: PageQuery) {
return requestClient.get<Tenant[]>(Api.tenantList, { params });
}
/**
*
* @param data data
* @returns void
*/
export function tenantExport(data: Partial<Tenant>) {
2024-09-23 09:47:47 +08:00
return commonExport(Api.tenantExport, data);
}
/**
*
* @param id id
* @returns
*/
2024-09-23 09:47:47 +08:00
export function tenantInfo(id: ID) {
return requestClient.get<Tenant>(`${Api.root}/${id}`);
}
/**
*
* @param data data
* @returns void
*/
export function tenantAdd(data: Partial<Tenant>) {
2024-09-23 09:47:47 +08:00
return requestClient.postWithMsg<void>(Api.root, data, { encrypt: true });
}
/**
*
* @param data data
* @returns void
*/
export function tenantUpdate(data: Partial<Tenant>) {
2024-09-23 09:47:47 +08:00
return requestClient.putWithMsg<void>(Api.root, data);
}
/**
*
* @param data data
* @returns void
*/
export function tenantStatusChange(data: Partial<Tenant>) {
2024-09-23 09:47:47 +08:00
return requestClient.putWithMsg(Api.tenantStatus, data);
}
/**
*
* @param ids ids
* @returns void
*/
2024-09-23 09:47:47 +08:00
export function tenantRemove(ids: IDS) {
return requestClient.deleteWithMsg(`${Api.root}/${ids}`);
}
2024-08-07 11:55:13 +08:00
/**
*
* @param tenantId ID
* @returns void
*/
export function tenantDynamicToggle(tenantId: string) {
return requestClient.get<void>(`${Api.tenantDynamic}/${tenantId}`);
}
/**
*
* @returns void
*/
export function tenantDynamicClear() {
return requestClient.get<void>(Api.tenantDynamicClear);
}
2024-09-23 09:47:47 +08:00
/**
*
* @param tenantId id
* @param packageId id
* @returns void
*/
export function tenantSyncPackage(tenantId: string, packageId: string) {
2024-09-23 09:47:47 +08:00
return requestClient.get<void>(Api.tenantSyncPackage, {
params: { packageId, tenantId },
successMessageMode: 'message',
2024-09-23 09:47:47 +08:00
});
}
/**
*
* @param tenantId ID
* @returns void
*/
export function dictSyncTenant(tenantId?: string) {
return requestClient.get<void>(Api.dictSync, {
params: { tenantId },
successMessageMode: 'message',
});
}