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

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

enum Api {
  List = '/authorize/manage/item/list',
  Delete = '/authorize/manage/item/delete',
  Detail = '/authorize/manage/item/detail',
  Update = '/authorize/manage/item/update',
}

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

/**
 * @description: 删除接口
 */
export function authorizeClassItemDeleteApi(
  id: number | string,
  mode: ErrorMessageMode = 'message',
) {
  return defHttp.post<any[]>(
    {
      url: `${Api.Delete}/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}

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

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