import axios from '@/api/axios.ts'
import { BasePaginationData, BaseRespData } from '@/types/api'
import {
  IntercategoryTree,
  InterSearchCriteriaWithStatus,
  InterCardItem,
  ProductDetail,
  InterCraftItem,
} from '@/types/api/product'
// 状态统计列表
export function getStatusCountApi() {
  return axios.get<never, BaseRespData<IntercategoryTree[]>>(
    'custom/product/info/getStatusCountList',
  )
}
export function getCardListPageApi(
  data: InterSearchCriteriaWithStatus,
  currentPage: number,
  pageSize: number,
) {
  return axios.post<never, BasePaginationData<InterCardItem>>(
    'custom/product/info/page',
    {
      ...data,
      currentPage,
      pageSize,
    },
  )
}
// 类目树
export function getcategoryTreeApi() {
  return axios.get<never, BaseRespData<IntercategoryTree[]>>(
    'custom/product/info/categoryTree',
  )
}
// 工艺列表
export function getcraftListApi() {
  return axios.get<never, BaseRespData<InterCraftItem[]>>(
    'custom/product/info/craftList',
  )
}
// 所有币种
export function getAllCurrencyApi() {
  return axios.get<never, BaseRespData<IntercategoryTree[]>>(
    'custom/product/info/getAllCurrency',
  )
}
// 根据类别获取属性值
export function getByCateIdApi(id: number) {
  return axios.get<never, BaseRespData<never>>(
    'custom/product/info/getByCateId',
    { params: { id } },
  )
}
// 状态转换
export function updateStatusApi(data?: {
  ids: string
  status?: string | number
  remark?: string | null
}) {
  return axios.post<never, BaseRespData<never>>(
    'custom/product/info/updateStatus',
    data,
  )
}
// 新增商品
export function createProductApi(from: ProductDetail) {
  return axios.post<never, BaseRespData<never>>('custom/product/info/create', {
    ...from,
  })
}
// 编辑商品
export function updateProductApi(from: ProductDetail) {
  return axios.post<never, BaseRespData<never>>('custom/product/info/update', {
    ...from,
  })
}
// 操作日志
export function getLogListApi(id: number) {
  return axios.get<never, BaseRespData<never>>(
    'custom/product/info/getLogList',
    { params: { id } },
  )
}
// 查看详情
export function getByIdApi(id: number) {
  return axios.get<never, BaseRespData<never>>('custom/product/info/getById', {
    params: { id },
  })
}
// 注册不通过=删除商品
export function deleteProductApi(data?: {
  ids: string
  remark?: string | null
}) {
  return axios.get<never, BaseRespData<never>>('custom/product/info/delete', {
    params: { ...data },
  })
}
