import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseFactoryInfoVO, BaseFactoryInfoForm, BaseFactoryInfoQuery } from '@/api/mes/baseFactoryInfo/types';

/**
 * 查询工厂信息列表
 * @param query
 * @returns {*}
 */
export const listBaseFactoryInfo = (query?: BaseFactoryInfoQuery): AxiosPromise<BaseFactoryInfoVO[]> => {
  return request({
    url: '/mes/baseFactoryInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工厂信息详细
 * @param factoryId
 */
export const getBaseFactoryInfo = (factoryId: string | number): AxiosPromise<BaseFactoryInfoVO> => {
  return request({
    url: '/mes/baseFactoryInfo/' + factoryId,
    method: 'get'
  });
};

/**
 * 新增工厂信息
 * @param data
 */
export const addBaseFactoryInfo = (data: BaseFactoryInfoForm) => {
  return request({
    url: '/mes/baseFactoryInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改工厂信息
 * @param data
 */
export const updateBaseFactoryInfo = (data: BaseFactoryInfoForm) => {
  return request({
    url: '/mes/baseFactoryInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除工厂信息
 * @param factoryId
 */
export const delBaseFactoryInfo = (factoryId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseFactoryInfo/' + factoryId,
    method: 'delete'
  });
};

/**
 * 查询工厂信息下拉框列表
 * @param query
 * @returns {*}
 */
export function getFactoryList(query) {
  return request({
    url: '/mes/baseFactoryInfo/getFactoryList',
    method: 'get',
    params: query
  });
};
