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

/** 获取PC列表（分页） */
export const fetchPCList = (data?: {
  page?: number;
  page_size?: number;
  keyword?: string;
  datacenter_id?: number;
  rack_id?: number;
  status?: string;
  sort?: string;
  order?: string;
}) => {
  return request.post("/Assets/v1/pc/list", data || {});
};

/** 获取PC详情 */
export const fetchPCDetail = (id: number) => {
  return request.get(`/Assets/v1/pc/detail/${id}`);
};

/** 创建PC */
export const createPC = (data: any) => {
  return request.post("/Assets/v1/pc/create", data);
};

/** 更新PC */
export const updatePC = (data: any) => {
  return request.put("/Assets/v1/pc/update", data);
};

/** 删除PC */
export const deletePC = (id: number) => {
  return request.delete(`/Assets/v1/pc/delete/${id}`);
};

/** 获取机柜列表（用于下拉选择） */
export const fetchRackListForSelect = (datacenterId?: number) => {
  return request.get("/Assets/v1/rack/all", { params: { datacenter_id: datacenterId } });
};
