/**
 * 账户名称映射工具
 * 数据库存储英文常量，前端显示中文名称
 */

export const ACCOUNT_NAMES = {
  SYSTEM_MAIN: 'SYSTEM_MAIN',
  PLATFORM_MAIN: 'PLATFORM_MAIN',
  PLATFORM_BACKUP: 'PLATFORM_BACKUP',
} as const;

export const ACCOUNT_NAME_MAP: Record<string, string> = {
  SYSTEM_MAIN: '系统总账户',
  PLATFORM_MAIN: '平台主账户',
  PLATFORM_BACKUP: '平台备用账户',
};

/**
 * 将英文账户名称转换为中文显示名称
 */
export function getAccountDisplayName(accountName: string): string {
  return ACCOUNT_NAME_MAP[accountName] || accountName;
}

/**
 * 将中文显示名称转换为英文账户名称
 */
export function getAccountConstName(displayName: string): string {
  const entry = Object.entries(ACCOUNT_NAME_MAP).find(([_, value]) => value === displayName);
  return entry ? entry[0] : displayName;
}
