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

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

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

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

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

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

/**
 * 修改签约
 * @param data 签约对象
 * @param neId 网元ID
 * @returns object
 */
export function updateSub(neId: string, data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/sub/${neId}`,
    method: 'put',
    data: data,
  });
}

/**
 * 新增签约
 * @param data 签约对象
 * @returns object
 */
export function addSub(neID: string, data: Record<string, any>) {
  return request({
    url: `/api/rest/udmUserManage/v1/sub/${neID}`,
    method: 'post',
    data: data,
  });
}

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

/**
 * 删除签约
 * @param data 签约对象
 * @returns object
 */
export function delSub(neId: string, imsi: string) {
  return request({
    url: `/api/rest/udmUserManage/v1/sub/${neId}/${imsi}`,
    method: 'delete',
  });
}

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