import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace SystemTenantApi {
  /** 租户信息 */
  export interface SystemTenant {
    id?: number;
    name: string;
    packageId: number;
    contactName: string;
    contactMobile: string;
    accountCount: number;
    expireTime: Date;
    website: string;
    status: number;
  }
}

/** 租户列表 */
export function getTenantPage(params: PageParam) {
  return requestClient.get<PageResult<SystemTenantApi.SystemTenant>>('/system/tenant/page', { params });
}

/** 获取租户精简信息列表 */
export function getSimpleTenantList() {
  return requestClient.get<SystemTenantApi.SystemTenant[]>('/system/tenant/simple-list');
}

/** 查询租户详情 */
export function getTenant(id: number) {
  return requestClient.get<SystemTenantApi.SystemTenant>(`/system/tenant/get?id=${id}`,);
}

/** 新增租户 */
export function createTenant(data: SystemTenantApi.SystemTenant) {
  return requestClient.post('/system/tenant/create', data);
}

/** 修改租户 */
export function updateTenant(data: SystemTenantApi.SystemTenant) {
  return requestClient.put('/system/tenant/update', data);
}

/** 删除租户 */
export function deleteTenant(id: number) {
  return requestClient.delete(`/system/tenant/delete?id=${id}`);
}

/** 导出租户 */
export function exportTenant(params: any) {
  return requestClient.download('/system/tenant/export-excel', {
    params,
  });
}
