import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RouteConfigVO, RouteConfigForm, RouteConfigQuery } from '@/api/system/routeConfig/types';

/**
 * 查询路由接口配置列表
 * @param query
 * @returns {*}
 */

export const listRouteConfig = (query?: RouteConfigQuery): AxiosPromise<RouteConfigVO[]> => {
  return request({
    url: '/system/routeConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询路由接口配置详细
 * @param configId
 */
export const getRouteConfig = (configId: string | number): AxiosPromise<RouteConfigVO> => {
  return request({
    url: '/system/routeConfig/' + configId,
    method: 'get'
  });
};

/**
 * 新增路由接口配置
 * @param data
 */
export const addRouteConfig = (data: RouteConfigForm) => {
  return request({
    url: '/system/routeConfig/add',
    method: 'post',
    data: data
  });
};

/**
 * 刷新缓存
 */
export const refreshCache = () => {
  return request({
    url: '/system/routeConfig/refreshCache',
    method: 'post'
  });
};

/**
 * 修改路由接口配置
 * @param data
 */
export const updateRouteConfig = (data: RouteConfigForm) => {
  return request({
    url: '/system/routeConfig/edit',
    method: 'put',
    data: data
  });
};

/**
 * 删除路由接口配置
 * @param configId
 */
export const delRouteConfig = (configId: string | number | Array<string | number>) => {
  return request({
    url: '/system/routeConfig/' + configId,
    method: 'delete'
  });
};
