Add complete NexaFabric project structure including: - FastAPI backend with SQLAlchemy models, JWT auth, RBAC, audit logging, and provider interfaces - React + TypeScript frontend with Vite, Tailwind CSS, TanStack Query, and Zustand - Docker Compose configuration for PostgreSQL, Redis, API, worker, frontend, and nginx - GitHub Actions and GitLab CI workflows for testing, linting, building, and security scanning - Environment
33 lines
702 B
Python
33 lines
702 B
Python
from sqlalchemy.orm import Session
|
|
|
|
from app.models.domain import AuditLog
|
|
|
|
|
|
def write_audit(
|
|
db: Session,
|
|
*,
|
|
action: str,
|
|
object_type: str,
|
|
object_id: str | None = None,
|
|
user_id: str | None = None,
|
|
old_values: dict | None = None,
|
|
new_values: dict | None = None,
|
|
result: str = "success",
|
|
error_text: str | None = None,
|
|
) -> AuditLog:
|
|
audit = AuditLog(
|
|
action=action,
|
|
object_type=object_type,
|
|
object_id=object_id,
|
|
user_id=user_id,
|
|
old_values=old_values,
|
|
new_values=new_values,
|
|
result=result,
|
|
error_text=error_text,
|
|
)
|
|
db.add(audit)
|
|
db.commit()
|
|
db.refresh(audit)
|
|
return audit
|
|
|