386 lines
14 KiB
TypeScript
386 lines
14 KiB
TypeScript
|
|
// =============================================================================
|
||
|
|
// 企微IT智能服务台 — 管理后台 API 调用函数
|
||
|
|
// =============================================================================
|
||
|
|
// 说明:封装所有管理后台 API 端点调用,统一返回类型
|
||
|
|
// 所有函数返回 axios response,调用方从 response.data.data 获取业务数据
|
||
|
|
|
||
|
|
import apiClient from './index'
|
||
|
|
import type {
|
||
|
|
DashboardOverview,
|
||
|
|
ConfigGroup,
|
||
|
|
UpdateConfigRequest,
|
||
|
|
UpdateConfigResponse,
|
||
|
|
PaginatedData,
|
||
|
|
ConfigChangeLogEntry,
|
||
|
|
Agent,
|
||
|
|
CreateAgentRequest,
|
||
|
|
UpdateAgentRequest,
|
||
|
|
Integration,
|
||
|
|
UpdateIntegrationRequest,
|
||
|
|
QuickReplyTemplate,
|
||
|
|
ReviewQuickReplyRequest,
|
||
|
|
ReviewQuickReplyResponse,
|
||
|
|
AssignmentModeConfig,
|
||
|
|
UpdateAssignmentModeRequest,
|
||
|
|
MonitorSessionsData,
|
||
|
|
SearchResults,
|
||
|
|
Role,
|
||
|
|
RoleAssignRequest,
|
||
|
|
RoleRevokeRequest,
|
||
|
|
RoleMappingRule,
|
||
|
|
RoleMappingRuleRequest,
|
||
|
|
} from '@/types'
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 运营总览
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取仪表盘统计数据 */
|
||
|
|
export function getDashboardOverview(): Promise<{ data: { code: number; data: DashboardOverview; message: string } }> {
|
||
|
|
return apiClient.get('/admin/dashboard/overview')
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 功能开关/参数管理
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取全部配置项(按功能分组) */
|
||
|
|
export function getConfigGroups(): Promise<{ data: { code: number; data: { groups: ConfigGroup[] }; message: string } }> {
|
||
|
|
return apiClient.get('/admin/configs')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 更新单个配置项 */
|
||
|
|
export function updateConfig(
|
||
|
|
key: string,
|
||
|
|
value: string
|
||
|
|
): Promise<{ data: { code: number; data: UpdateConfigResponse; message: string } }> {
|
||
|
|
const body: UpdateConfigRequest = { value }
|
||
|
|
return apiClient.put(`/admin/configs/${key}`, body)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取指定配置项的变更历史 */
|
||
|
|
export function getConfigHistory(
|
||
|
|
key: string,
|
||
|
|
limit: number = 20
|
||
|
|
): Promise<{ data: { code: number; data: { items: ConfigChangeLogEntry[] }; message: string } }> {
|
||
|
|
return apiClient.get(`/admin/configs/${key}/history`, { params: { limit } })
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 坐席管理
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取坐席列表(管理视图) */
|
||
|
|
export function getAgents(
|
||
|
|
status?: string
|
||
|
|
): Promise<{ data: { code: number; data: { items: Agent[] }; message: string } }> {
|
||
|
|
const params: Record<string, string> = {}
|
||
|
|
if (status && status !== 'all') {
|
||
|
|
params.status = status
|
||
|
|
}
|
||
|
|
return apiClient.get('/admin/agents', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 添加坐席 */
|
||
|
|
export function createAgent(
|
||
|
|
data: CreateAgentRequest
|
||
|
|
): Promise<{ data: { code: number; data: Agent; message: string } }> {
|
||
|
|
return apiClient.post('/admin/agents', data)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 编辑坐席 */
|
||
|
|
export function updateAgent(
|
||
|
|
id: string,
|
||
|
|
data: UpdateAgentRequest
|
||
|
|
): Promise<{ data: { code: number; data: Agent; message: string } }> {
|
||
|
|
return apiClient.put(`/admin/agents/${id}`, data)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// OTP 管理
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 强制解绑OTP */
|
||
|
|
export function unbindOtp(
|
||
|
|
id: string
|
||
|
|
): Promise<{ data: { code: number; data: { message: string }; message: string } }> {
|
||
|
|
return apiClient.post(`/admin/agents/${id}/otp-unbind`)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 移除坐席 */
|
||
|
|
export function deleteAgent(
|
||
|
|
id: string
|
||
|
|
): Promise<{ data: { code: number; data: null; message: string } }> {
|
||
|
|
return apiClient.delete(`/admin/agents/${id}`)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 外部系统集成配置
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取集成系统列表及配置状态 */
|
||
|
|
export function getIntegrations(): Promise<{ data: { code: number; data: { items: Integration[] }; message: string } }> {
|
||
|
|
return apiClient.get('/admin/integrations')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 更新集成配置(支持 url_key 和 access_key 两种模式) */
|
||
|
|
export function updateIntegration(
|
||
|
|
id: string,
|
||
|
|
data: UpdateIntegrationRequest
|
||
|
|
): Promise<{ data: { code: number; data: Integration; message: string } }> {
|
||
|
|
return apiClient.put(`/admin/integrations/${id}`, data)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 火绒安全集成 API
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 火绒连接测试结果 */
|
||
|
|
export interface HuorongTestResult {
|
||
|
|
success: boolean
|
||
|
|
message: string
|
||
|
|
total_terminals?: number
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 测试火绒API连接 */
|
||
|
|
export function testHuorongConnection(): Promise<{ data: { code: number; data: HuorongTestResult; message: string } }> {
|
||
|
|
return apiClient.post('/admin/integrations/huorong/test')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 火绒终端列表 */
|
||
|
|
export function getHuorongTerminals(
|
||
|
|
params?: { group_id?: string; page?: number; per_page?: number }
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get('/admin/integrations/huorong/terminals', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 火绒终端详情 */
|
||
|
|
export function getHuorongTerminalDetail(
|
||
|
|
clientId: string
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get(`/admin/integrations/huorong/terminals/${clientId}`)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 火绒漏洞信息 */
|
||
|
|
export function getHuorongLeaks(
|
||
|
|
params?: { group_id?: string; page?: number; per_page?: number }
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get('/admin/integrations/huorong/leaks', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 火绒病毒事件 */
|
||
|
|
export function getHuorongVirusEvents(
|
||
|
|
params?: { client_id?: string; group_id?: string; query_type?: number; page?: number; per_page?: number }
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get('/admin/integrations/huorong/virus-events', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 联软LV7000 安全集成 API
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 测试联软API连接 */
|
||
|
|
export function testLianruanConnection(): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.post('/admin/integrations/lianruan/test')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 联软终端查询(核心映射接口) */
|
||
|
|
export function queryLianruanTerminals(
|
||
|
|
params?: { strusername?: string; strdevname?: string; strdevip?: string; page?: number; per_page?: number }
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get('/admin/integrations/lianruan/terminals', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// RAGFlow 知识检索集成
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 测试 RAGFlow API 连接 */
|
||
|
|
export function testRagflowConnection(): Promise<{ data: { code: number; data: { success: boolean; message: string }; message: string } }> {
|
||
|
|
return apiClient.post('/admin/integrations/ragflow/test')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 列出 RAGFlow 知识库(数据集) */
|
||
|
|
export function getRagflowDatasets(params?: {
|
||
|
|
page?: number
|
||
|
|
page_size?: number
|
||
|
|
}): Promise<{ data: { code: number; data: { items: any[]; total: number }; message: string } }> {
|
||
|
|
return apiClient.get('/admin/integrations/ragflow/datasets', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** RAGFlow 知识检索测试 */
|
||
|
|
export function ragflowRetrieval(params: {
|
||
|
|
question: string
|
||
|
|
dataset_ids?: string
|
||
|
|
top_k?: number
|
||
|
|
}): Promise<{ data: { code: number; data: { chunks: any[]; doc_aggs: any[]; total: number }; message: string } }> {
|
||
|
|
return apiClient.post('/admin/integrations/ragflow/retrieval', null, { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 联软终端详细信息 */
|
||
|
|
export function getLianruanTerminalDetail(
|
||
|
|
devname: string
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get(`/admin/integrations/lianruan/terminals/${encodeURIComponent(devname)}/detail`)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 快速回复审核
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取待审核模板列表 */
|
||
|
|
export function getPendingQuickReplies(
|
||
|
|
category?: string
|
||
|
|
): Promise<{ data: { code: number; data: { items: QuickReplyTemplate[] }; message: string } }> {
|
||
|
|
const params: Record<string, string> = {}
|
||
|
|
if (category && category !== '全部') {
|
||
|
|
params.category = category
|
||
|
|
}
|
||
|
|
return apiClient.get('/admin/quick-replies/pending', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 审核快速回复模板(通过/驳回) */
|
||
|
|
export function reviewQuickReply(
|
||
|
|
id: string,
|
||
|
|
action: string,
|
||
|
|
reason?: string
|
||
|
|
): Promise<{ data: { code: number; data: ReviewQuickReplyResponse; message: string } }> {
|
||
|
|
const body: ReviewQuickReplyRequest = { action: action as ReviewQuickReplyRequest['action'], reason }
|
||
|
|
return apiClient.put(`/admin/quick-replies/${id}/review`, body)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 消息分配模式
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取当前分配模式 */
|
||
|
|
export function getAssignmentMode(): Promise<{ data: { code: number; data: AssignmentModeConfig; message: string } }> {
|
||
|
|
return apiClient.get('/admin/assignment-mode')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 切换分配模式 */
|
||
|
|
export function updateAssignmentMode(
|
||
|
|
mode: string
|
||
|
|
): Promise<{ data: { code: number; data: AssignmentModeConfig; message: string } }> {
|
||
|
|
const body: UpdateAssignmentModeRequest = { mode }
|
||
|
|
return apiClient.put('/admin/assignment-mode', body)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 会话监控
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取实时会话列表(Demo预览) */
|
||
|
|
export function getMonitorSessions(
|
||
|
|
status?: string
|
||
|
|
): Promise<{ data: { code: number; data: MonitorSessionsData; message: string } }> {
|
||
|
|
const params: Record<string, string> = {}
|
||
|
|
if (status) {
|
||
|
|
params.status = status
|
||
|
|
}
|
||
|
|
return apiClient.get('/admin/monitor/sessions', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 全局搜索
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 搜索配置项、坐席、快速回复 */
|
||
|
|
export function globalSearch(
|
||
|
|
query: string
|
||
|
|
): Promise<{ data: { code: number; data: SearchResults; message: string } }> {
|
||
|
|
return apiClient.get('/admin/search', { params: { q: query } })
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// 角色管理
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取所有角色列表(含用户数量统计) */
|
||
|
|
export function getRoles(): Promise<{ data: { code: number; data: Role[]; message: string } }> {
|
||
|
|
return apiClient.get('/admin/roles')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 手动分配角色给用户 */
|
||
|
|
export function assignRole(
|
||
|
|
data: RoleAssignRequest
|
||
|
|
): Promise<{ data: { code: number; data: null; message: string } }> {
|
||
|
|
return apiClient.post('/admin/roles/assign', data)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 撤销用户角色 */
|
||
|
|
export function revokeRole(
|
||
|
|
data: RoleRevokeRequest
|
||
|
|
): Promise<{ data: { code: number; data: null; message: string } }> {
|
||
|
|
return apiClient.post('/admin/roles/revoke', data)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取所有角色映射规则 */
|
||
|
|
export function getRoleMappingRules(): Promise<{ data: { code: number; data: RoleMappingRule[]; message: string } }> {
|
||
|
|
return apiClient.get('/admin/roles/mapping-rules')
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 创建角色映射规则 */
|
||
|
|
export function createRoleMappingRule(
|
||
|
|
data: RoleMappingRuleRequest
|
||
|
|
): Promise<{ data: { code: number; data: { id: string }; message: string } }> {
|
||
|
|
return apiClient.post('/admin/roles/mapping-rules', data)
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 删除角色映射规则 */
|
||
|
|
export function deleteRoleMappingRule(
|
||
|
|
ruleId: string
|
||
|
|
): Promise<{ data: { code: number; data: null; message: string } }> {
|
||
|
|
return apiClient.delete(`/admin/roles/mapping-rules/${ruleId}`)
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// P2: 会话审计
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取会话审计列表 */
|
||
|
|
export function getAuditConversations(params?: {
|
||
|
|
status?: string
|
||
|
|
agent_id?: string
|
||
|
|
keyword?: string
|
||
|
|
date_from?: string
|
||
|
|
date_to?: string
|
||
|
|
page?: number
|
||
|
|
page_size?: number
|
||
|
|
}): Promise<{ data: { code: number; data: { items: any[]; total: number; page: number; page_size: number }; message: string } }> {
|
||
|
|
return apiClient.get('/admin/audit/conversations', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 获取会话审计详情(含消息列表) */
|
||
|
|
export function getAuditConversationDetail(
|
||
|
|
conversationId: string
|
||
|
|
): Promise<{ data: { code: number; data: any; message: string } }> {
|
||
|
|
return apiClient.get(`/admin/audit/conversations/${conversationId}`)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// P2: 坐席绩效统计
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取坐席绩效统计 */
|
||
|
|
export function getAgentPerformance(params?: {
|
||
|
|
date_from?: string
|
||
|
|
date_to?: string
|
||
|
|
}): Promise<{ data: { code: number; data: { items: any[] }; message: string } }> {
|
||
|
|
return apiClient.get('/admin/agent-performance', { params })
|
||
|
|
}
|
||
|
|
|
||
|
|
// ==========================================================================
|
||
|
|
// P2: 系统日志
|
||
|
|
// ==========================================================================
|
||
|
|
|
||
|
|
/** 获取系统日志(配置变更日志) */
|
||
|
|
export function getSystemLogs(params?: {
|
||
|
|
page?: number
|
||
|
|
page_size?: number
|
||
|
|
}): Promise<{ data: { code: number; data: { items: any[]; total: number; page: number; page_size: number }; message: string } }> {
|
||
|
|
return apiClient.get('/admin/system-logs', { params })
|
||
|
|
}
|