export * from './find-menu-by-path';
export * from './generate-menus';
export * from './generate-routes-backend';
export * from './generate-routes-frontend';
export * from './get-popup-container';
export * from './merge-route-modules';
export * from './reset-routes';
export * from './storage';
export * from './unmount-global-loading';

/**
 * 后端数据格式化为json数据
 * {
      "usersid": {
          "label": "用户id",
          "disable": false,
          "value": "1"
      },
      "usersname": {
          "label": "用户名称",
          "disable": false,
          "value": "123"
      },
   }
   转换为
   {
      usersid: '1',
      usersname: '123',
   }
 */
export const formatBackendJson = (obj: Record<string, any>) => {
  const result: Record<string, any> = {};
  for (const key in obj) {
    result[key] = obj[key].value;
  }
  return result;
};

/**
 * 将请求的参数{key: value}转换为{key.value: value}  兼容  后端list的条件查询 和 详情请求
 * @param obj
 * @returns obj
 */
export const parseQueryValues = (obj: Record<string, any>) => {
  const result: Record<string, any> = {};
  for (const key in obj) {
    result[`${key}.value`] = obj[key];
  }
  return result;
};
