import api from './client'; import type { AccountExchangeRecords, AccountEventPage, AccountItem, AccountBulkSelection, AccountBulkTagRequest, AccountExportRequest, AccountOverview, AssignmentsSummary, BasicSummary, BatchAssignRequest, MessageCountResponse, MessageDeletedResponse, MessageResponse, PageParams, PaginatedResponse, } from './types'; export const accountApi = { list: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_sensitive?: boolean }) => api.get('/accounts', { params }), listPaged: ( params: PageParams & { assigned_only?: boolean; assign_status?: string; assigned_user_id?: number; tag?: string; has_cookie?: boolean; include_sensitive?: boolean; status?: string; ck_status?: string; failure_kind?: string; bind_status?: string; high_value_filter?: string; min_points?: number; max_points?: number; min_gold?: number; max_gold?: number; elite_opened?: boolean; esports_opened?: boolean; role_bind_status?: string; sort?: 'username' | 'status' | 'bind' | 'points' | 'high_value' | 'exchange' | 'tag'; order?: 'asc' | 'desc'; }, ) => api.get, PaginatedResponse>('/accounts', { params }), export: (data: AccountExportRequest) => api.post('/accounts/export', data, { responseType: 'blob' }), summary: () => api.get('/accounts/summary'), import: (text: string, tag?: string) => api.post('/accounts/import', { text, tag: tag || '' }), assign: (id: number, assigned_to: number | null) => api.put(`/accounts/${id}/assign`, { assigned_to }), batchAssign: (account_ids: number[], assigned_to: number | null) => api.post('/accounts/batch-assign', { account_ids, assigned_to }), // 同一接口的选择集版本:可带筛选条件(all_matching),供「按筛选全选」分配 batchAssignSelection: (data: BatchAssignRequest) => api.post('/accounts/batch-assign', data), assignmentsSummary: () => api.get('/accounts/assignments/summary'), setRemark: (id: number, remark: string) => api.put(`/accounts/${id}/remark`, { remark }), setTag: (id: number, tag: string) => api.put(`/accounts/${id}/tag`, { tag }), batchTag: (account_ids: number[], tag: string) => api.put('/accounts/batch-tag', { account_ids, tag }), batchTagSelection: (data: AccountBulkTagRequest) => api.put('/accounts/batch-tag-selection', data), listTags: () => api.get('/accounts/tags/list'), delete: (id: number) => api.delete(`/accounts/${id}`), batchDelete: (account_ids: number[]) => api.delete('/accounts/batch/delete', { params: { account_ids: account_ids.join(',') } }), batchDeleteSelection: (data: AccountBulkSelection) => api.post('/accounts/batch-delete', data), // 生命周期:disabled / archived / auto(恢复自动推导) setLifecycle: (id: number, status: string, reason = '') => api.put(`/accounts/${id}/lifecycle`, { status, reason }), // 自动化开关:false = 账号可用但自动化不碰它 setAutomation: (id: number, auto_managed: boolean) => api.put(`/accounts/${id}/automation`, { auto_managed }), // 详情页:状态卡 + 统计 overview: (id: number) => api.get(`/accounts/${id}/overview`), // 三个作用域的**官方**兑换记录(点列表那一格时按需拉取,不进列表响应) exchangeRecords: (id: number) => api.get(`/accounts/${id}/exchange-records`), // 时间线(倒序分页),event_type 为空表示全部 events: ( id: number, params: { page?: number; page_size?: number; event_type?: string; category?: string }, ) => api.get(`/accounts/${id}/events`, { params: { page: 1, page_size: 50, ...params, event_type: params.event_type || '', category: params.category || '', }, }), };