import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {MasterDataDetailVO, MasterDataDetailForm, MasterDataDetailQuery} from '@/api/system/masterDataDetail/types';

/**
 * 查询主数据维护明细页面配置
 * @param query
 * @returns {*}
 */

export const listMasterData = (query) => {
  return request({
    url: '/system/masterData/list',
    method: 'get',
    params: query
  });
};


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

export const listMasterDataDetail = (query?: MasterDataDetailQuery): AxiosPromise<MasterDataDetailVO[]> => {
  return request({
    url: '/system/masterDataDetail/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增主数据维护明细
 * @param data
 */
export const addMasterDataDetail = (data: MasterDataDetailForm) => {
  return request({
    url: '/system/masterDataDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改主数据维护明细
 * @param data
 */
export const updateMasterDataDetail = (data: MasterDataDetailForm) => {
  return request({
    url: '/system/masterDataDetail',
    method: 'put',
    data: data
  });
};

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


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