import { request } from "@/api/request";

/** 许可证配置（与 DC-Control `LicenceConfig` / 接口 `data` 一致；字段按实际响应可能部分缺失） */
export interface LicenceConfig {
  title?: string
  version?: string
  company_name?: string
  create_time?: string
  expire_time?: string
  machine_code?: string
  max_database?: number
  max_middleware?: number
  max_pc?: number
  max_server?: number
  max_client?: number
  max_user?: number
  max_role?: number
  max_permission?: number
  max_menu?: number
}

/** 获取 采集器 */
export const fetchCollectors = (data: { page: number, size: number, keyword?: string }) => request.get("/DC-Control/v1/collectors", { params: data });

/** 新增 采集器 */
export const createCollector = (data: any) => request.post("/DC-Control/v1/collectors", data);

/** 删除 采集器 */
export const deleteCollector = (id: number) => request.delete(`/DC-Control/v1/collectors/${id}`);

/** 获取 采集器详情 */
export const fetchCollectorDetail = (id: number) => request.get(`/DC-Control/v1/collectors/${id}`);

/** 更新 采集器 */
export const updateCollector = (data: any) => request.put(`/DC-Control/v1/collectors/${data.id}`, data);

/** 获取 采集器统计数据 */
export const fetchCollectorStatistics = () => request.get("/DC-Control/v1/statistics");

/** 获取 许可证信息 */
export const fetchLicenseInfo = () =>
  request.get<{ code?: number; data?: LicenceConfig; message?: string }>("/DC-Control/v1/license");
