diff --git a/internal/api/http/v1/stats_handler.go b/internal/api/http/v1/stats_handler.go index d081b3f9..e3bb6c1a 100644 --- a/internal/api/http/v1/stats_handler.go +++ b/internal/api/http/v1/stats_handler.go @@ -344,8 +344,8 @@ func (h *statsHandler) biz(c *gin.Context) { var rows []row if err := h.db.Model(&entity.MessageTask{}). Where("created_at >= ?", start).Scopes(statsTaskScope(c)). - Select("COALESCE(NULLIF(business,''),'sms') AS key, COUNT(*) AS count"). - Group("key").Order("count DESC").Scan(&rows).Error; err != nil { + Select("COALESCE(NULLIF(business,''),'sms') AS `key`, COUNT(*) AS count"). + Group("`key`").Order("count DESC").Scan(&rows).Error; err != nil { bizResp(c, err) return } @@ -356,8 +356,8 @@ func (h *statsHandler) biz(c *gin.Context) { rows = nil if err := h.db.Model(&entity.MessageTask{}). Where("created_at >= ?", start).Scopes(statsTaskScope(c)). - Select("send_type AS key, COUNT(*) AS count"). - Group("key").Order("count DESC").Scan(&rows).Error; err != nil { + Select("send_type AS `key`, COUNT(*) AS count"). + Group("`key`").Order("count DESC").Scan(&rows).Error; err != nil { bizResp(c, err) return } diff --git a/web-next/src/api/channel.ts b/web-next/src/api/channel.ts index b20e1877..3ede7839 100644 --- a/web-next/src/api/channel.ts +++ b/web-next/src/api/channel.ts @@ -130,7 +130,26 @@ export interface ChannelPriceEntry { created_at?: string } +/** 通道实时快照(Day 40:/channels/monitor,与 WS 帧同构;60s 窗口均值)。 */ +export interface ChannelSnapshot { + channel_id: number + name: string + protocol: string + status: number + running: boolean + total: number + healthy: number + submit_ps: number + deliver_ps: number + fail_rate: number + latency_p50_ms: number + updated_at: string +} + export const channelApi = { + // ---- 实时监控(Day 40:HTTP 快照,与 /channels/monitor/ws 帧同构) ---- + monitor: () => get('/channels/monitor'), + // ---- 上家 ---- upstreamList: (q?: { page: number; page_size: number; name?: string }) => get>('/channels/upstreams', q as Record), diff --git a/web-next/src/api/stats.ts b/web-next/src/api/stats.ts index ec15ab4f..4903e423 100644 --- a/web-next/src/api/stats.ts +++ b/web-next/src/api/stats.ts @@ -29,4 +29,23 @@ export const statsApi = { // 叠加成 /api/v1/api/v1/... → msw 不匹配 → proxy 404(Home 指标一直空数据)。 summary: () => get('/stats/summary'), trend: (days = 7) => get('/stats/trend', { days }), + // ---- Issue#6·P2 Dashboard 三端点(openapi 1.5.0) ---- + biz: (days = 7) => get('/stats/biz', { days }), + realtime: () => get('/stats/realtime'), } + +/** 业务类型分布(P2:/stats/biz)。 */ +export interface BizDist { + days: number + by_business: { key: string; count: number }[] + by_send_type: { key: string; count: number }[] +} + +/** 实时提交速率(P2:/stats/realtime,60s 窗口均值)。 */ +export interface RealtimeStat { + ts: string + window_s: number + global_submit_ps: number + top_accounts: { account_id: number; name: string; submit_ps: number }[] +} + diff --git a/web-next/src/api/system.ts b/web-next/src/api/system.ts index 737b117b..c04b64ea 100644 --- a/web-next/src/api/system.ts +++ b/web-next/src/api/system.ts @@ -31,6 +31,15 @@ export const KNOWN_CFG_KEYS: { key: string; label: string; hint: string }[] = [ ] export const systemApi = { + // ---- Issue#6·P2:/ops/system/overview(admin/ops;gateway 视角五子系统三态) ---- + overview: () => get('/ops/system/overview'), list: () => get<{ list: SystemConfigRow[] }>('/system/config'), update: (body: SystemConfigSaveReq) => put('/system/config', body), } + +/** 系统健康总览(P2:/ops/system/overview)。 */ +export interface SystemOverview { + uptime_s: number + subsystems: { name: string; status: 'up' | 'degraded' | 'down' | 'unknown'; detail: string; latency_ms: number }[] +} + diff --git a/web-next/src/router/routes.ts b/web-next/src/router/routes.ts index 6a7a42c4..9dddcfb1 100644 --- a/web-next/src/router/routes.ts +++ b/web-next/src/router/routes.ts @@ -30,10 +30,10 @@ export const asyncRoutes: RouteRecordRaw[] = [ component: () => import('@/layouts/BasicLayout.vue'), redirect: '/home', children: [ - { path: 'home', name: 'home', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '运营总览', icon: 'i-grid', menu: true, group: '工作台', subtitle: '今日平台运行概览 · 60s 自动刷新', roles: ['admin', 'ops', 'service', 'group', 'customer'] } }, + { path: 'home', name: 'home', component: () => import('@/views/home/DashboardView.vue'), meta: { title: '运营总览', icon: 'i-grid', menu: true, group: '工作台', subtitle: '今日平台运行概览 · 60s 自动刷新', roles: ['admin', 'ops', 'service', 'group', 'customer'] } }, { path: 'notice', name: 'notice', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '预警公告', icon: 'i-bell', menu: true, group: '工作台', roles: ['admin', 'ops', 'service', 'group'] } }, - { path: 'account', name: 'account-list', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '帐号管理', icon: 'i-users', menu: true, group: '运营管理', roles: ['admin', 'ops'] } }, + { path: 'account', name: 'account-list', component: () => import('@/views/account/AccountList.vue'), meta: { title: '帐号管理', icon: 'i-users', menu: true, group: '运营管理', roles: ['admin', 'ops'] } }, { path: 'account/create', name: 'account-create', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '开户', group: '运营管理', roles: ['admin', 'ops'] } }, { path: 'account/:id', name: 'account-detail', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '账号详情', group: '运营管理', roles: ['admin', 'ops'] } }, { path: 'account/:id/recharge', name: 'account-recharge', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '充值', group: '运营管理', roles: ['admin', 'ops'] } }, @@ -63,7 +63,7 @@ export const asyncRoutes: RouteRecordRaw[] = [ { path: 'channel', name: 'channel', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道配置', icon: 'i-layer', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'channel/upstream', name: 'channel-upstream', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '上家管理', icon: 'i-srv', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, - { path: 'channel/edit/:id?', name: 'channel-edit', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道编辑', group: '通道与策略', roles: ['admin', 'ops'] } }, + { path: 'channel/edit/:id?', name: 'channel-edit', component: () => import('@/views/channel/ChannelEdit.vue'), meta: { title: '通道编辑', group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'channel/group', name: 'channel-group', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道组路由', icon: 'i-route', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'policy', name: 'policy', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '规则策略', icon: 'i-set', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'policy/route', name: 'policy-route', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '导流策略', icon: 'i-route', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, diff --git a/web-next/src/views/account/AccountList.vue b/web-next/src/views/account/AccountList.vue new file mode 100644 index 00000000..2113197c --- /dev/null +++ b/web-next/src/views/account/AccountList.vue @@ -0,0 +1,187 @@ + + + + diff --git a/web-next/src/views/channel/ChannelEdit.vue b/web-next/src/views/channel/ChannelEdit.vue new file mode 100644 index 00000000..812d0a74 --- /dev/null +++ b/web-next/src/views/channel/ChannelEdit.vue @@ -0,0 +1,210 @@ + + + + diff --git a/web-next/src/views/home/DashboardView.vue b/web-next/src/views/home/DashboardView.vue new file mode 100644 index 00000000..f4c46688 --- /dev/null +++ b/web-next/src/views/home/DashboardView.vue @@ -0,0 +1,501 @@ + + + + +