128 lines
4.5 KiB
TypeScript
128 lines
4.5 KiB
TypeScript
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<Paged<NumberList>>('/policies/blacklist', q as Record<string, unknown>),
|
|
blacklistAdd: (body: { mobile: string }) => post<NumberList>('/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<Paged<NumberList>>('/policies/whitelist', q as Record<string, unknown>),
|
|
whitelistAdd: (body: { mobile: string }) => post<NumberList>('/policies/whitelist', body),
|
|
whitelistRemove: (id: number) => del<{ id: number }>(`/policies/whitelist/${id}`),
|
|
|
|
// 关键字
|
|
keywords: (q?: { page: number; page_size: number; level?: number }) =>
|
|
get<Paged<Keyword>>('/policies/keywords', q as Record<string, unknown>),
|
|
keywordAdd: (body: { word: string; level: number }) => post<Keyword>('/policies/keywords', body),
|
|
keywordRemove: (id: number) => del<{ id: number }>(`/policies/keywords/${id}`),
|
|
|
|
// 频次策略
|
|
frequencies: () => get<Paged<FrequencyPolicy>>('/policies/frequencies'),
|
|
frequencyCreate: (body: Partial<FrequencyPolicy>) => post<FrequencyPolicy>('/policies/frequencies', body),
|
|
frequencyUpdate: (id: number, body: Partial<FrequencyPolicy>) => put<FrequencyPolicy>(`/policies/frequencies/${id}`, body),
|
|
|
|
// 屏蔽码号
|
|
blockedCodes: (q?: { page: number; page_size: number }) =>
|
|
get<Paged<BlockedCode>>('/policies/blocked-codes', q as Record<string, unknown>),
|
|
blockedCodeAdd: (body: { channel_id: number; code: string }) => post<BlockedCode>('/policies/blocked-codes', body),
|
|
blockedCodeRemove: (id: number) => del<{ id: number }>(`/policies/blocked-codes/${id}`),
|
|
|
|
// 导流策略
|
|
routeRules: () => get<Paged<RouteRule>>('/policies/route-rules'),
|
|
routeRuleCreate: (body: Partial<RouteRule>) => post<RouteRule>('/policies/route-rules', body),
|
|
routeRuleUpdate: (id: number, body: Partial<RouteRule>) => put<RouteRule>(`/policies/route-rules/${id}`, body),
|
|
routeRuleRemove: (id: number) => del<{ id: number }>(`/policies/route-rules/${id}`),
|
|
// 签名/码号报备(D16)
|
|
reports: () => get<Paged<Report>>('/policies/reports'),
|
|
reportCreate: (body: { type: 'sign' | 'code'; content: string }) => post<Report>('/policies/reports', body),
|
|
reportReview: (id: number, approve: boolean) => post<Report>(`/policies/reports/${id}/review`, { approve }),
|
|
reportResubmit: (id: number) => post<Report>(`/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
|