1
0
forked from erp-dev/erp

feat: added ApiAuditLog

This commit is contained in:
2026-01-12 11:52:41 +08:00
parent 3036cbdc5b
commit 5741a8cdef
7 changed files with 435 additions and 4 deletions

View File

@@ -0,0 +1,34 @@
# Generated by Django 5.2.8 on 2026-01-12 03:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api_v1', '0008_alter_datasync_table_name'),
]
operations = [
migrations.CreateModel(
name='ApiAuditLog',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.CharField(help_text='完整的请求路径', max_length=500, verbose_name='请求URL')),
('method', models.CharField(help_text='HTTP方法如POST', max_length=10, verbose_name='请求方法')),
('request_data', models.JSONField(default=dict, help_text='POST请求的body数据JSON格式', verbose_name='请求体数据')),
('query_params', models.JSONField(default=dict, help_text='URL查询参数', verbose_name='查询参数')),
('user_id', models.IntegerField(blank=True, db_index=True, help_text='操作用户的ID', null=True, verbose_name='用户ID')),
('username', models.CharField(blank=True, default='', help_text='操作用户的用户名快照', max_length=150, verbose_name='用户名')),
('response_status', models.IntegerField(blank=True, help_text='HTTP响应状态码', null=True, verbose_name='响应状态码')),
('created_at', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')),
],
options={
'verbose_name': 'API审计日志',
'verbose_name_plural': 'API审计日志',
'db_table': 'api_audit_log',
'ordering': ['-created_at'],
'indexes': [models.Index(fields=['user_id', 'created_at'], name='api_audit_l_user_id_b15ad2_idx'), models.Index(fields=['url', 'created_at'], name='api_audit_l_url_338a46_idx')],
},
),
]