"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Badge } from "@/components/ui/badge" import { Database, Server, Link, Plus, FileText, RefreshCw } from "lucide-react" export default function DataIntegrationPage() { const [activeTab, setActiveTab] = useState("data-sources") const [isDialogOpen, setIsDialogOpen] = useState(false) return (

数据中台

管理数据源和API接口

数据集成 API管理
) } // 数据源管理标签页 function DataSourcesTab({ setIsDialogOpen }: { setIsDialogOpen: (open: boolean) => void }) { // 模拟数据源列表 const dataSources = [ { id: "1", name: "用户数据库", type: "MySQL", host: "db.example.com", status: "connected", lastSync: "2023-07-20 15:30", tables: 24, records: 156789, }, { id: "2", name: "订单系统", type: "PostgreSQL", host: "orders.example.com", status: "connected", lastSync: "2023-07-19 12:45", tables: 18, records: 89456, }, { id: "3", name: "内容库", type: "MongoDB", host: "content.example.com", status: "error", lastSync: "2023-07-15 09:20", tables: 12, records: 45678, }, { id: "4", name: "用户行为分析", type: "ClickHouse", host: "analytics.example.com", status: "connected", lastSync: "2023-07-20 10:15", tables: 8, records: 2345678, }, { id: "5", name: "CRM系统", type: "Oracle", host: "crm.example.com", status: "pending", lastSync: "等待连接", tables: 0, records: 0, }, ] return (

数据源管理

已连接的数据源 管理和监控所有数据源连接 数据源名称 类型 主机地址 状态 最后同步 表数量 记录数 操作 {dataSources.map((source) => (
{source.name}
{source.type} {source.host} {source.status === "connected" ? "已连接" : source.status === "error" ? "错误" : "等待中"} {source.lastSync} {source.tables} {source.records.toLocaleString()}
))}
数据源类型 支持的数据库和数据源类型
MySQL 关系型数据库
PostgreSQL 关系型数据库
MongoDB 文档型数据库
ClickHouse 列式数据库
Oracle 关系型数据库
SQL Server 关系型数据库
Redis 键值存储
CSV/Excel 文件导入
) } // API管理标签页 function ApiManagementTab() { // 模拟API接口数据 const apiEndpoints = [ { id: "1", name: "用户数据API", endpoint: "/api/users", method: "GET", category: "用户画像", status: "active", calls: 12567, lastCalled: "2023-07-20 16:45", }, { id: "2", name: "用户标签API", endpoint: "/api/users/tags", method: "GET", category: "用户画像", status: "active", calls: 8945, lastCalled: "2023-07-20 15:30", }, { id: "3", name: "流量池数据API", endpoint: "/api/traffic-pools", method: "GET", category: "流量池", status: "active", calls: 5678, lastCalled: "2023-07-20 14:20", }, { id: "4", name: "AI分析API", endpoint: "/api/ai/analyze", method: "POST", category: "AI分析", status: "active", calls: 3456, lastCalled: "2023-07-20 13:15", }, { id: "5", name: "数据同步API", endpoint: "/api/sync", method: "POST", category: "数据集成", status: "maintenance", calls: 2345, lastCalled: "2023-07-19 10:30", }, ] // 模拟API密钥数据 const apiKeys = [ { id: "1", name: "Web应用", key: "sk_web_*************", created: "2023-05-15", lastUsed: "2023-07-20", status: "active", }, { id: "2", name: "移动应用", key: "sk_mobile_*************", created: "2023-06-10", lastUsed: "2023-07-19", status: "active", }, { id: "3", name: "第三方集成", key: "sk_partner_*************", created: "2023-04-20", lastUsed: "2023-07-18", status: "active", }, ] return (

API接口管理

API接口列表 所有可用的API接口 API名称 接口地址 方法 分类 状态 调用次数 最后调用 操作 {apiEndpoints.map((api) => ( {api.name} {api.endpoint} {api.method} {api.category} {api.status === "active" ? "正常" : "维护中"} {api.calls.toLocaleString()} {api.lastCalled}
))}
API密钥管理 管理API访问密钥 应用名称 密钥 创建时间 最后使用 状态 操作 {apiKeys.map((key) => ( {key.name} {key.key} {key.created} {key.lastUsed} {key.status === "active" ? "有效" : "已禁用"}
))}
API使用统计 API调用量和性能统计

API调用统计图表

) } // 添加数据源对话框 function AddDataSourceDialog({ isOpen, setIsOpen }: { isOpen: boolean; setIsOpen: (open: boolean) => void }) { const [dbType, setDbType] = useState("mysql") return ( 添加新数据源 连接到新的数据库或数据源
) }