/**
 * @desc 增加权限
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
import type { AxiosResponse } from 'axios';
export default async function (
  /** 请求体 */
  requestBody: acl.Permission,

  success: (data: acl.Permission) => void = defaultSuccess,
  fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
  return http({
    method: 'post',
    url: `/permission`,
    data: requestBody,
  })
    .then((data: AxiosResponse<acl.Permission, unknown>) => {
      success(data.data);
    })
    .catch((error: { code: string; error?: string }) => fail(error));
}
