import { defHttp } from '/@/utils/http/axios';

import { ErrorMessageMode, Result } from '/#/axios';

enum Api {
  List = '/authorize/list',
  GetDropdown = '/authorize/getDropdown',
  Detail = '/authorize/detail',
  Update = '/authorize/update',
}

/**
 * @description: 接口授权列表
 */
export function authorizeListApi(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post<any[]>(
    {
      url: Api.List,
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 接口授权列表
 */
export function authorizeGetDropdownApi(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post<any[]>(
    {
      url: Api.GetDropdown,
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 新增/编辑接口授权
 */
export function authorizeUpdateApi(data: any, mode: ErrorMessageMode = 'message') {
  return defHttp.post<Result<null>>(
    {
      url: Api.Update,
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * @description: 详情
 */
export function authorizeCloseApi(id: number, mode: ErrorMessageMode = 'message') {
  return defHttp.get<any>(
    {
      url: `${Api.Detail}/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}
