import { request } from '@/http/axios'
import type { CabinetDetailResponse } from './type'
import { OpenCabinetApiData } from '../shop/type'

/** 获取智能柜详情接口 */
export function getCabinetDetailApi(shopId: number) {
  return request<CabinetDetailResponse>({
    url: 'cabinet/detail',
    method: 'get',
    params: {
      shopId
    }
  })
}

export function openCabinet(cabinetId: number, pinNo: number, data: OpenCabinetApiData) {
  return request<ApiResponseData<void>>({
    url: `cabinet/openCabinet/${cabinetId}/${pinNo}`,
    method: 'post',
    data
  })
}

export const configureGoodsCellsStock = (cellId: number, goodsId: number, stock: number) => {
  return request<ApiResponseData<void>>({
    url: `/cabinet/configureGoodsCellsStock/${cellId}/${goodsId}/${stock}`,
    method: 'put'
  });
};

export const changeGoodsCellsStock = (cellId: number, stock: number) => {
  return request<ApiResponseData<void>>({
    url: `/cabinet/changeGoodsCellsStock/${cellId}/${stock}`,
    method: 'put'
  });
};

export const clearGoodsCells = (cellId: number) => {
  return request<ApiResponseData<void>>({ 
    url: `/cabinet/clearGoodsCells/${cellId}`,
    method: 'put'
  });
};

