import { del, get, post, put } from './request' import type { Paged } from './account' /** 黑/白名单。 */ export interface NumberList { id: number mobile: string account_id: number source: number operator: string created_at: string } /** 关键字。 */ export interface Keyword { id: number word: string level: 1 | 2 | 3 // 1一级黑 2二级黑 3白 status: number operator: string created_at: string } /** 频次策略。 */ export interface FrequencyPolicy { id: number account_id: number dim: 1 | 2 // 1同号码 2同内容 window_unit: 1 | 2 // 1自然日 2滚动24h max_count: number status: number created_at: string } /** 屏蔽码号。 */ export interface BlockedCode { id: number channel_id: number code: string remark: string created_at: string } /** 导流规则。 */ export interface RouteRule { id: number account_id: number channel_id: number channel_name?: string rule_type: 'keyword' | 'region' | 'account' | 'content' rule_config: string priority: number status: number created_at: string } /** 签名/码号报备。 */ export interface Report { id: number type: 'sign' | 'code' content: string account_id: number status: 0 | 1 | 2 // 0 待审 1 通过 2 驳回(可重提) operator: string created_at: string } export const REPORT_TYPES = [ { value: 'sign', label: '签名报备' }, { value: 'code', label: '码号报备' }, ] as const export const policyApi = { // 黑名单 blacklist: (q?: { page: number; page_size: number; mobile?: string }) => get>('/policies/blacklist', q as Record), blacklistAdd: (body: { mobile: string }) => post('/policies/blacklist', body), blacklistRemove: (id: number) => del<{ id: number }>(`/policies/blacklist/${id}`), blacklistImport: (body: { mobiles: string[] }) => post<{ imported: number }>('/policies/blacklist/import', body), // 白名单 whitelist: (q?: { page: number; page_size: number }) => get>('/policies/whitelist', q as Record), whitelistAdd: (body: { mobile: string }) => post('/policies/whitelist', body), whitelistRemove: (id: number) => del<{ id: number }>(`/policies/whitelist/${id}`), // 关键字 keywords: (q?: { page: number; page_size: number; level?: number }) => get>('/policies/keywords', q as Record), keywordAdd: (body: { word: string; level: number }) => post('/policies/keywords', body), keywordRemove: (id: number) => del<{ id: number }>(`/policies/keywords/${id}`), // 频次策略 frequencies: () => get>('/policies/frequencies'), frequencyCreate: (body: Partial) => post('/policies/frequencies', body), frequencyUpdate: (id: number, body: Partial) => put(`/policies/frequencies/${id}`, body), // 屏蔽码号 blockedCodes: (q?: { page: number; page_size: number }) => get>('/policies/blocked-codes', q as Record), blockedCodeAdd: (body: { channel_id: number; code: string }) => post('/policies/blocked-codes', body), blockedCodeRemove: (id: number) => del<{ id: number }>(`/policies/blocked-codes/${id}`), // 导流策略 routeRules: () => get>('/policies/route-rules'), routeRuleCreate: (body: Partial) => post('/policies/route-rules', body), routeRuleUpdate: (id: number, body: Partial) => put(`/policies/route-rules/${id}`, body), routeRuleRemove: (id: number) => del<{ id: number }>(`/policies/route-rules/${id}`), // 签名/码号报备(D16) reports: () => get>('/policies/reports'), reportCreate: (body: { type: 'sign' | 'code'; content: string }) => post('/policies/reports', body), reportReview: (id: number, approve: boolean) => post(`/policies/reports/${id}/review`, { approve }), reportResubmit: (id: number) => post(`/policies/reports/${id}/resubmit`, {}), } export const KEYWORD_LEVELS = [ { value: 1, label: '一级黑', tag: 'danger', desc: '强制失败' }, { value: 2, label: '二级黑', tag: 'warning', desc: '免审模式专用' }, { value: 3, label: '白名单', tag: 'success', desc: '免审直通' }, ] as const export const RULE_TYPES = [ { value: 'keyword', label: '关键字' }, { value: 'region', label: '地区' }, { value: 'account', label: '账号' }, { value: 'content', label: '内容' }, ] as const