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

export interface Category extends PageParam {
  parentId?: number;
  categoryName?: string; //类目名称
  categoryId?: number; //类目ID
  grade?: number; //类目层级
  parentName?: string; //父级类目
  sort?: number; //排序权重
  status?: number; // 1为开启 0 为禁用;
  createTime?: Date;
  description?: string; //描述
  tag?: string[] | string;
}

export interface CategoryReq extends PageParam {
  parentName?: string;
  categoryName?: string;
  status?: number;
  grade?: number; //父级类目
}

// 查询分类列表
export const getProdCategoryPage = async (params: CategoryReq) => {
  return request("/product/category/categoryList", {
    method: "GET",
    params,
  });
};
// 新增分类
export const createProdCategory = async (data: Category) => {
  return request("/product/category/create", {
    method: "GET",
    data,
  });
};
//编辑分类
export const updateProdCategory = async (data: Category) => {
  return request<IResponse<boolean>>("/product/category/create", {
    method: "PUT",
    data,
  });
};
