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 listIMS(query: Record<string, any>) {
  query.nbId = query.id;
  const result = await request({
    url: '/api/rest/ueManagement/v1/elementType/ims/objectType/ueInfo',
    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;
  }
  return data;
}
