feat: add stage 0 foundation

This commit is contained in:
hailin
2026-06-30 15:55:46 +08:00
parent 6d373da09f
commit 604f456e03
68 changed files with 4884 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
from django.conf import settings
from django.db import models
class OperationAuditLog(models.Model):
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="operation_audit_logs",
)
module = models.CharField(max_length=80)
action = models.CharField(max_length=80)
target_type = models.CharField(max_length=80)
target_id = models.CharField(max_length=120, blank=True)
request_snapshot = models.JSONField(default=dict, blank=True)
result = models.CharField(max_length=20)
ip_address = models.GenericIPAddressField(null=True, blank=True)
user_agent = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ["-created_at"]
indexes = [
models.Index(fields=["module", "action"]),
models.Index(fields=["target_type", "target_id"]),
models.Index(fields=["created_at"]),
]
def __str__(self) -> str:
return f"{self.module}.{self.action}:{self.result}"