
import type spu from "~/domain/Spu";
import type skuQuery from "./skuQuery";
import { type skuStockType } from "~/domain/Sku";
import { type SkuStockQuery, type skuInquiryQuery } from "./skuQuery";

import type { ServerList, ServerRes } from '~/service/index'
import httpRequest from "~/service/index";

export function useSku() {
  const apiRoot = "/seller/sku"
  async function getSkuList(req?: skuQuery) {
    return await httpRequest.post(`${apiRoot}/list`, req)
  }
  async function getSkuPrice(id: string) {
    return await httpRequest.get<ServerRes<any>>(`/seller/sku/get/${id}`)
  }

  async function getSkuStock(req: SkuStockQuery) {
    return await httpRequest.post<ServerRes<skuStockType>>(`/seller/skuStock/get`, req)
  }

  async function skuInquiry(req: skuInquiryQuery) {
    return await httpRequest.post<ServerRes<skuStockType>>(`/seller/sku/inquiry`, req)
  }

  return {
    getSkuList,
    getSkuPrice, getSkuStock, skuInquiry
  }
}
