import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { request } from '@/plugins/http-fetch';
import { parseObjLineToHump } from '@/utils/parse-utils';

/**
 * 查询列表
 * @param query 查询参数
 * @returns object
 */
export async function listBase5G(query: Record<string, any>) {
  const result = await request({
    url: `/api/rest/ueManagement/v1/elementType/${query.neType.toLowerCase()}/objectType/nbInfo`,
    method: 'get',
    params: query,
  });
  let data: DataList = {
    total: 0,
    rows: [],
    code: result.code,
    msg: result.msg,
  };
  // 解析数据
  if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) {
    const rows = parseObjLineToHump(result.data.data);
    data.total = rows.length;
    data.rows = rows;
  }

  // 模拟数据
  // data.rows = [{"address":"192.168.1.137:38412","id":"217","name":"attach-enb-100000-20","ueNum":0}]
  // data.rows = [{address: "192.168.8.223", id: 257, name: "SmallCell", ueNum: 0}]

  return data;
}
