import type { PageParam } from '@/api'

/**
 * 云账号凭证
 */
export interface AppCloudCredential {
  id?: number
  userId?: number
  tenantId?: number
  name?: string
  provider?: string // aliyun/tencent/huawei/qiniu
  accessKeyId?: string // AK
  accessKeySecret?: string // SK (AES加密存储)
  status?: number // 0-禁用 1-启用
  testStatus?: number // 0-未测试 1-测试成功 2-测试失败
  testMessage?: string
  remark?: string
  deleted?: number
  createTime?: string
  updateTime?: string
}

/**
 * 查询参数
 */
export interface AppCloudCredentialParam extends PageParam {
  provider?: string
  status?: number
  name?: string
}

/**
 * 云服务商选项
 */
export const CLOUD_PROVIDER_OPTIONS = [
  { label: '阿里云 OSS', value: 'aliyun', icon: '🟢' },
  { label: '腾讯云 COS', value: 'tencent', icon: '🔵' },
  { label: '华为云 OBS', value: 'huawei', icon: '🟠' },
  { label: '七牛云 Kodo', value: 'qiniu', icon: '🟡' },
]

/**
 * 获取云服务商显示文本
 */
export function getProviderLabel(provider: string) {
  const opt = CLOUD_PROVIDER_OPTIONS.find((i) => i.value === provider)
  return opt ? `${opt.icon} ${opt.label}` : provider
}

/**
 * 获取云服务商图标
 */
export function getProviderIcon(provider: string) {
  const iconMap: Record<string, string> = {
    aliyun: '🟢',
    tencent: '🔵',
    huawei: '🟠',
    qiniu: '🟡',
  }
  return iconMap[provider] || '☁️'
}