import http from "../utils/http";
import type {
  // ProductListItem,
  ProductCategory,
  ProductDetail,
  ProductPageParams,
  ProductPageResponse,
} from "@/types/product";

// 获取商品列表
export const getProductList = (params: ProductPageParams) => {
  return http<ProductPageResponse>({
    url: "/product/page",
    method: "get",
    params,
  });
};

// 获取商品分类
export const getProductCategories = () => {
  return http<ProductCategory[]>({
    url: "/product/category",
    method: "get",
  });
};

// 获取子分类
export const getProductSubCategories = (id: number) => {
  return http<ProductCategory[]>({
    url: `/product/category/${id}`,
    method: "get",
  });
};

// 获取商品详情
export const getProductDetail = (id: number) => {
  return http<ProductDetail>({
    url: `/product/${id}`,
    method: "get",
  });
};
