import { request, type ApiResponse } from './request'
|
|
interface PlatformOperationLog {
|
operId: number
|
operName: string
|
title: string
|
method: string
|
businessType: number
|
operParam: string
|
operTime: string
|
status: number
|
}
|
|
export interface OperationLogRecord {
|
id: number
|
operator: string
|
content: string
|
operatedAt: string
|
}
|
|
function operationContent(item: PlatformOperationLog) {
|
if (item.method === 'compare-report.delete') {
|
try {
|
const identity = JSON.parse(item.operParam)
|
if (typeof identity.reportId === 'number' && typeof identity.reportName === 'string')
|
return `删除对比报表“${identity.reportName}”(#${identity.reportId})及全部版本`
|
} catch { /* 非结构化平台日志仍展示模块与动作。 */ }
|
}
|
const actions = ['操作', '新增', '修改', '删除', '授权', '导出', '导入', '强退', '生成代码', '清空数据']
|
return `${item.title}:${actions[item.businessType] || '操作'}(${item.status === 0 ? '成功' : '失败'})`
|
}
|
|
/** 读取正式平台日志供既有本地筛选分页使用,不展示通用请求或响应中的业务内容。 */
|
export async function listOperationLogs(): Promise<OperationLogRecord[]> {
|
const records: PlatformOperationLog[] = []
|
for (let pageNum = 1; ; pageNum++) {
|
const result = await request<ApiResponse & { rows: PlatformOperationLog[]; total: number }>(`/monitor/operlog/list?pageNum=${pageNum}&pageSize=100`)
|
records.push(...result.rows)
|
if (!result.rows.length || records.length >= result.total) break
|
}
|
return records.map(item => ({ id: item.operId, operator: item.operName || '-',
|
content: operationContent(item), operatedAt: item.operTime || '',
|
}))
|
}
|