mengstack-website/api/audit.md
MengStack Dev fca3326e34 docs: 官网文档全面更新 — M2-M8 指南 + API 参考 + v0.2.0 更新日志
- 更新 changelog.md: v0.2.0 记录 M2-M8 全部完成,路线图更新
- 新增 5 篇指南: RBAC、组织管理、审计日志、通知模块、质量横切
- 新增 5 篇 API 文档: RBAC(11)、Org(5)、Audit(1)、Settings(7)、Notification(7)
- 更新 api/overview.md: 完整 37 端点列表
- 更新 config.ts: 侧边栏分组 + 11 页 SEO 元数据
2026-10-03 01:55:55 +08:00

61 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 审计日志 API | 操作审计查询接口 - MengStack官方文档
---
# 审计日志接口
所有接口需要认证,并携带 `X-Tenant-ID` 头。
## 查询审计日志
**`GET /api/v1/audit/logs`**
### 查询参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| `user_id` | int | 否 | 按操作人 ID 筛选 |
| `action` | string | 否 | 按操作类型筛选(create / update / delete / login / assign) |
| `resource` | string | 否 | 按资源类型筛选(user / role / tenant / setting / auth) |
| `page` | int | 否 | 页码,默认 1 |
| `page_size` | int | 否 | 每页条数,默认 20 |
### 响应
```json
{
"code": 0,
"data": {
"items": [
{
"id": 1,
"tenant_id": "550e8400-...",
"user_id": 1,
"action": "create",
"resource": "role",
"resource_id": "5",
"detail": "{\"name\":\"editor\"}",
"ip": "192.168.1.100",
"created_at": "2026-10-03T10:00:00+08:00"
}
],
"total": 42,
"page": 1
}
}
```
### 示例
```bash
# 查询所有删除操作
curl "http://localhost:2222/api/v1/audit/logs?action=delete" \
-H "Authorization: Bearer <token>" \
-H "X-Tenant-ID: <tenant_id>"
# 查询指定用户的日志
curl "http://localhost:2222/api/v1/audit/logs?user_id=1&page_size=10" \
-H "Authorization: Bearer <token>" \
-H "X-Tenant-ID: <tenant_id>"
```