import type { PageParams, PageResult } from '@/types/global'
import type {
  goodsListItem,
  goodsListParams,
  goodsResult,
  goodsServiceItem,
  goodsShareResult,
} from '@/types/goods'
import { request } from '@/utils/request'

export const getGoodsListApi = (data?: PageParams & goodsListParams) => {
  return request<PageResult<goodsListItem>>({
    method: 'GET',
    url: '/shop/goods',
    data,
  })
}

export const getGoodsByIdApi = (id: number) => {
  return request<goodsResult>({
    method: 'GET',
    url: '/shop/goods/detail',
    data: {
      id,
    },
  })
}

export const getGoodsServiceApi = (service_ids: string) => {
  return request<goodsServiceItem[]>({
    method: 'GET',
    url: '/shop/goods/service',
    data: {
      service_ids,
    },
  })
}

export const getShareInfoApi = (id: number) => {
  return request<goodsShareResult>({
    method: 'GET',
    url: '/shop/goods/share',
    data: {
      id,
    },
  })
}
