import { http } from '@/utils/http'
import type { ProductUserScqyType } from '@/types/product-user-scqy'
import type { ListType, ListResponseType } from '@/types/list'
import { parseQueryValues } from '@/utils'

/** 商品列表 */
export const getProductListApi = (
  params: Partial<ProductUserScqyType>,
  page: Partial<ListType>,
) => {
  return http.get<ListResponseType<ProductUserScqyType>>('/api/query/list?pagevalue=59', {
    ...page,
    // ...parseQueryValues(params),
    'productsmerchantid.find': params.productsmerchantid,
  })
}

/** 获取商品详情 */
export const getProductDetailApi = ({
  productsid,
  merchantid,
}: {
  productsid: string
  merchantid: string
}) => {
  return http.get<ProductUserScqyType>(
    '/api/query/view?pagevalue=60',
    {
      ...parseQueryValues({ productsid }),
      'usersid.value': merchantid,
    },
    {
      formatData: true,
    },
  )
}
