import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FunctionMenuVO, FunctionMenuForm, FunctionMenuQuery } from '@/api/system/functionMenu/types';

/**
 * 查询功能菜单列表
 * @param query
 * @returns {*}
 */

export const listFunctionMenu = (query?: FunctionMenuQuery): AxiosPromise<FunctionMenuVO[]> => {
  return request({
    url: '/system/functionMenu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询功能菜单详细
 * @param id
 */
export const getFunctionMenu = (id: string | number): AxiosPromise<FunctionMenuVO> => {
  return request({
    url: '/system/functionMenu/' + id,
    method: 'get'
  });
};

/**
 * 新增功能菜单
 * @param data
 */
export const addFunctionMenu = (data: FunctionMenuForm) => {
  return request({
    url: '/system/functionMenu',
    method: 'post',
    data: data
  });
};

/**
 * 修改功能菜单
 * @param data
 */
export const updateFunctionMenu = (data: FunctionMenuForm) => {
  return request({
    url: '/system/functionMenu',
    method: 'put',
    data: data
  });
};

/**
 * 删除功能菜单
 * @param id
 */
export const delFunctionMenu = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/functionMenu/' + id,
    method: 'delete'
  });
};
