import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MasterDataVO, MasterDataForm, MasterDataQuery } from '@/api/system/masterData/types';

/**
 * 查询主数据维护列表
 * @param query
 * @returns {*}
 */

export const listMasterData = (query?: MasterDataQuery): AxiosPromise<MasterDataVO[]> => {
  return request({
    url: '/system/masterData/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询主数据维护详细
 * @param masterDataId
 */
export const getMasterData = (masterDataId: string | number): AxiosPromise<MasterDataVO> => {
  return request({
    url: '/system/masterData/' + masterDataId,
    method: 'get'
  });
};

/**
 * 新增主数据维护
 * @param data
 */
export const addMasterData = (data: MasterDataForm) => {
  return request({
    url: '/system/masterData',
    method: 'post',
    data: data
  });
};

/**
 * 修改主数据维护
 * @param data
 */
export const updateMasterData = (data: MasterDataForm) => {
  return request({
    url: '/system/masterData',
    method: 'put',
    data: data
  });
};

/**
 * 删除主数据维护
 * @param masterDataId
 */
export const delMasterData = (masterDataId: string | number | Array<string | number>) => {
  return request({
    url: '/system/masterData/' + masterDataId,
    method: 'delete'
  });
};


/**
 * 下拉框查询主数据维护列表
 * @param query
 * @returns {*}
 */
export function getSysMasterDataList (query) {
    return request({
        url: '/system/masterData/getSysMasterDataList',
        method: 'get',
        params: query
    });
};
