import { request } from "@umijs/max";

export interface TenantVO {
  id: number;
  name: string;
  contactName: string;
  contactMobile: string;
  status: number;
  domain: string;
  packageId: number;
  username: string;
  password: string;
  expireTime: Date | number;
  accountCount: number;
  createTime: Date;
}

export interface TenantPageReqVO extends PageParam {
  name?: string;
  contactName?: string;
  contactMobile?: string;
  status?: number;
  createTime?: Date[];
}

export interface TenantExportReqVO {
  name?: string;
  contactName?: string;
  contactMobile?: string;
  status?: number;
  createTime?: Date[];
}

// 查询租户列表
// export const getTenantPage = (params: TenantPageReqVO) => {
//   return request.get({ url: '/system/tenant/page', params })
// }
export async function getTenantPage(params: TenantPageReqVO) {
  return request("/system/tenant/page", {
    method: "GET",
    params,
  });
}
// 查询租户详情
// export const getTenant = (id: number) => {
//   return request.get({ url: "/system/tenant/get?id=" + id });
// };
export async function getTenant(id: number) {
  return request("/system/tenant/get", {
    method: "GET",
    params: { id },
  });
}
// 新增租户
// export const createTenant = (data: TenantVO) => {
//   return request.post({ url: "/system/tenant/create", data });
// };
export async function createTenant(data: TenantVO) {
  return request("/system/tenant/create", {
    method: "POST",
    data,
  });
}
// 修改租户
// export const updateTenant = (data: TenantVO) => {
//   return request.put({ url: "/system/tenant/update", data });
// };
export async function updateTenant(data: TenantVO) {
  return request("/system/tenant/update", {
    method: "PUT",
    headers: {
      "Content-Type": "application/json",
    },
    data,
  });
}
// 删除租户
// export const deleteTenant = (id: number) => {
//   return request.delete({ url: "/system/tenant/delete?id=" + id });
// };
export async function deleteTenant(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  id: number
) {
  return request("/system/tenant/delete", {
    method: "DELETE",
    params: {
      id,
    },
  });
}
