feat(admin): Add activity logs page and fix AI chat markdown rendering
- Add paginated activity logs API with filters (date, module, action, keyword) - Add ActivityLogsPage with table, filters, and detail modal - Add markdown rendering support for AI chat messages - Remove prototype placeholder content from chat sidebar Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -98,6 +98,81 @@ export async function getUserOverview(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询运营日志
|
||||
* GET /api/admin/stats/logs
|
||||
*
|
||||
* 查询参数:
|
||||
* - page: 页码 (默认1)
|
||||
* - pageSize: 每页条数 (默认20, 最大100)
|
||||
* - startDate: 开始日期 (YYYY-MM-DD)
|
||||
* - endDate: 结束日期 (YYYY-MM-DD)
|
||||
* - module: 模块筛选
|
||||
* - action: 动作筛选
|
||||
* - keyword: 关键词搜索 (用户名/租户名)
|
||||
*/
|
||||
export async function getActivityLogs(
|
||||
request: FastifyRequest<{
|
||||
Querystring: {
|
||||
page?: string;
|
||||
pageSize?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
module?: string;
|
||||
action?: string;
|
||||
keyword?: string;
|
||||
}
|
||||
}>,
|
||||
reply: FastifyReply
|
||||
) {
|
||||
try {
|
||||
const {
|
||||
page: pageStr,
|
||||
pageSize: pageSizeStr,
|
||||
startDate: startDateStr,
|
||||
endDate: endDateStr,
|
||||
module,
|
||||
action,
|
||||
keyword,
|
||||
} = request.query;
|
||||
|
||||
// 解析分页参数
|
||||
const page = Math.max(1, Number(pageStr) || 1);
|
||||
const pageSize = Math.min(100, Math.max(1, Number(pageSizeStr) || 20));
|
||||
|
||||
// 解析日期参数
|
||||
const startDate = startDateStr ? new Date(startDateStr) : undefined;
|
||||
const endDate = endDateStr ? new Date(endDateStr) : undefined;
|
||||
|
||||
const result = await activityService.getActivityLogs({
|
||||
page,
|
||||
pageSize,
|
||||
startDate,
|
||||
endDate,
|
||||
module,
|
||||
action,
|
||||
keyword,
|
||||
});
|
||||
|
||||
return reply.send({
|
||||
success: true,
|
||||
data: result.data,
|
||||
pagination: {
|
||||
page: result.page,
|
||||
pageSize: result.pageSize,
|
||||
total: result.total,
|
||||
totalPages: Math.ceil(result.total / result.pageSize),
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
logger.error('[StatsController] 获取运营日志失败', { error: error.message });
|
||||
return reply.status(500).send({
|
||||
success: false,
|
||||
message: error.message || '获取运营日志失败',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理过期日志(管理接口)
|
||||
* POST /api/admin/stats/cleanup
|
||||
|
||||
Reference in New Issue
Block a user