import request from './request'
import type {
  Good,
  CreateGoodRequest,
  UpdateGoodRequest,
  BatchCreateGoodsRequest,
  UpdatePriorityRequest,
  GoodsFilter,
  PaginatedResult,
} from '@/types'

export const goodsApi = {
  // Get goods list
  getGoodsList: (params: GoodsFilter) => {
    return request.get<any, PaginatedResult<Good>>('/goods', { params })
  },

  // Get good by id
  getGoodById: (id: string) => {
    return request.get<any, Good>(`/goods/${id}`)
  },

  // Create good
  createGood: (data: CreateGoodRequest) => {
    return request.post<any, Good>('/goods', data)
  },

  // Update good
  updateGood: (id: string, data: UpdateGoodRequest) => {
    return request.patch<any, Good>(`/goods/${id}`, data)
  },

  // Delete good
  deleteGood: (id: string) => {
    return request.delete(`/goods/${id}`)
  },

  // Batch create goods
  batchCreateGoods: (data: BatchCreateGoodsRequest) => {
    return request.post<any, Good[]>('/goods/batch', data)
  },

  // Update priority
  updatePriority: (data: UpdatePriorityRequest) => {
    return request.patch<any, Good[]>('/goods/priority', data)
  },
}