import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MachineryForm, MachineryQuery, MachineryVO } from '@/api/machinery/machinery/types';

/**
 * 查询机械列表
 * @param query
 * @returns {*}
 */

export const listMachinery = (query?: MachineryQuery): AxiosPromise<MachineryVO[]> => {
  return request({
    url: '/machinery/machinery/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询机械详细
 * @param id
 */
export const getMachinery = (id: string | number): AxiosPromise<MachineryVO> => {
  return request({
    url: '/machinery/machinery/' + id,
    method: 'get'
  });
};

/**
 * 新增机械
 * @param data
 */
export const addMachinery = (data: MachineryForm): AxiosPromise<string | number> => {
  return request({
    url: '/machinery/machinery',
    method: 'post',
    data: data
  });
};

/**
 * 修改机械
 * @param data
 */
export const updateMachinery = (data: MachineryForm) => {
  return request({
    url: '/machinery/machinery',
    method: 'put',
    data: data
  });
};

/**
 * 删除机械
 * @param id
 */
export const delMachinery = (id: string | number | Array<string | number>) => {
  return request({
    url: '/machinery/machinery/' + id,
    method: 'delete'
  });
};
