import { request } from '@/plugins/http-fetch';

/**
 * 签约鉴权导出
 * @param query 查询参数
 * @returns bolb
 */
export function exportAuth(query: Record<string, any>) {
  return request({
    url: '/api/rest/udmUserManage/v1/authExport',
    method: 'post',
    data: query,
    responseType: 'blob',
  });
}

/**
 * 导入鉴权数据
 * @param neId 网元ID
 * @param data 表单数据对象
 * @returns object
 */
export function importAuthData(neId: string, data: FormData) {
  return request({
    url: `/api/rest/udmUserManage/v1/authImport/${neId}`,
    method: 'post',
    data,
    dataType: 'form-data',
  });
}

/**
 * 查询鉴权列表
 * @param query 查询参数
 * @returns object
 */
export function listAuth(query: Record<string, any>) {
  return request({
    url: '/api/rest/udmUserManage/v1/auths',
    method: 'get',
    params: query,
  });
}

/**
 * 查询重新更新加载全部
 * @param neId 网元ID
 * @returns object
 */
export function loadAuth(neId: string) {
  return request({
    url: `/api/rest/udmUserManage/v1/authSave/${neId}`,
    method: 'post',
    timeout: 60 * 1000,
  });
}

/**
 * 查询鉴权详细
 * @param neId 网元ID
 * @returns object
 */
export function getAuth(neId: string, imsi: string) {
  return request({
    url: `/api/rest/udmUserManage/v1/auth/${neId}/${imsi}`,
    method: 'get',
  });
}

/**
 * 修改鉴权
 * @param data 鉴权对象
 * @returns object
 */
export function updateAuth(data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/auth/${data.neId}`,
    method: 'put',
    data: data,
  });
}

/**
 * 新增鉴权
 * @param data 鉴权对象
 * @returns object
 */
export function addAuth(data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/auth/${data.neId}`,
    method: 'post',
    data: data,
  });
}

/**
 * 批量新增鉴权
 * @param data 鉴权对象
 * @returns object
 */
export function batchAuth( data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/auth/${data.neID}/${data.num}`,
    method: 'post',
    data: data,
  });
}

/**
 * 删除鉴权
 * @param data 鉴权对象
 * @returns object
 */
export function delAuth(neId: string, data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/auth/${neId}/${data.imsi}`,
    method: 'delete',
  });
}



/**
 * 批量删除鉴权
 * @param data 鉴权对象
 * @returns object
 */
export function batchDelAuth(data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/auth/${data.neID}/${data.imsi}/${data.num}`,
    method: 'delete',
  });
}
