2026-08-03 09:34:08 +08:00
|
|
|
|
import { get } from '../request'
|
|
|
|
|
|
import request from '../request'
|
|
|
|
|
|
|
|
|
|
|
|
export interface AuditLog {
|
|
|
|
|
|
id: string
|
|
|
|
|
|
tenant_id?: string
|
|
|
|
|
|
project_id?: string
|
|
|
|
|
|
actor_id?: string
|
|
|
|
|
|
action?: string
|
|
|
|
|
|
target_type?: string
|
|
|
|
|
|
target_id?: string
|
|
|
|
|
|
detail?: string
|
|
|
|
|
|
client_ip?: string
|
2026-08-21 09:49:48 +08:00
|
|
|
|
result?: string
|
|
|
|
|
|
reason?: string
|
|
|
|
|
|
request_id?: string
|
|
|
|
|
|
session_id?: string
|
|
|
|
|
|
metadata?: string | Record<string, unknown>
|
2026-08-03 09:34:08 +08:00
|
|
|
|
time?: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface AuditQuery {
|
|
|
|
|
|
tenant_id?: string
|
|
|
|
|
|
project_id?: string
|
|
|
|
|
|
actor_id?: string
|
|
|
|
|
|
action?: string
|
|
|
|
|
|
target_type?: string
|
2026-08-19 16:10:02 +08:00
|
|
|
|
target_id?: string
|
|
|
|
|
|
keyword?: string
|
2026-08-03 09:34:08 +08:00
|
|
|
|
start_time?: string
|
|
|
|
|
|
end_time?: string
|
|
|
|
|
|
limit?: number
|
|
|
|
|
|
offset?: number
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** 审计日志查询:使用 get 辅助函数,拦截器已解包,直接返回 { items, total } */
|
|
|
|
|
|
export const getAuditLogs = (query: AuditQuery = {}) =>
|
|
|
|
|
|
get<{ items: AuditLog[]; total: number }>('/system/audit-logs', query)
|
|
|
|
|
|
|
|
|
|
|
|
/** 审计日志导出 CSV:blob 响应走完整 axios response,需手动取 data */
|
|
|
|
|
|
export const exportAuditLogs = (query: AuditQuery = {}) =>
|
|
|
|
|
|
request<Blob>({
|
|
|
|
|
|
url: '/system/audit-logs/export',
|
|
|
|
|
|
method: 'get',
|
|
|
|
|
|
params: query,
|
|
|
|
|
|
responseType: 'blob',
|
|
|
|
|
|
}).then((res) => res.data)
|