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

/** 获取资产分类列表（分页） */
export const fetchCategoryList = (data?: {
  page?: number;
  page_size?: number;
  keyword?: string;
  parent_id?: number;
}) => {
  return request.post("/Assets/v1/category/list", data || {});
};

/** 获取资产分类详情 */
export const fetchCategoryDetail = (id: number) => {
  return request.get(`/Assets/v1/category/detail/${id}`);
};

/** 创建资产分类 */
export const createCategory = (data: any) => {
  return request.post("/Assets/v1/category/create", data);
};

/** 更新资产分类 */
export const updateCategory = (data: any) => {
  return request.put("/Assets/v1/category/update", data);
};

/** 删除资产分类 */
export const deleteCategory = (id: number) => {
  return request.delete(`/Assets/v1/category/delete/${id}`);
};

/** 获取所有资产分类（用于下拉选择） */
export const fetchAllCategories = () => {
  return request.get("/Assets/v1/category/all");
};

/** 获取资产分类树形结构 */
export const fetchCategoryTree = () => {
  return request.get("/Assets/v1/category/tree");
};

/** 获取指定分类的子分类列表 */
export const fetchCategoryChildren = (id: number) => {
  return request.get(`/Assets/v1/category/children/${id}`);
};
