import { get, post } from '@/utils/request'
import type { ApiResponse, MachineDTO, MachineAddRequest, MachineUpdateRequest } from '@/types'

// 获取机器列表
export function listMachines(): Promise<ApiResponse<MachineDTO[]>> {
  return get('/admin/machines/list')
}

// 获取机器详情
export function getMachine(id: number): Promise<ApiResponse<MachineDTO>> {
  return get('/admin/machines/detail', { id })
}

// 添加机器
export function addMachine(data: MachineAddRequest): Promise<ApiResponse<MachineDTO>> {
  return post('/admin/machines/add', data)
}

// 更新机器
export function updateMachine(data: MachineUpdateRequest): Promise<ApiResponse<MachineDTO>> {
  return post('/admin/machines/update', data)
}

// 删除机器
export function deleteMachine(id: number): Promise<ApiResponse<null>> {
  return post('/admin/machines/delete', undefined, {
    params: { id }
  })
}
