complete new audit system
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Request, Response } from 'express';
|
||||
import * as contractHistoryService from '../services/contractHistory.service.js';
|
||||
import { logChange } from '../services/audit.service.js';
|
||||
import { ApiResponse, AuthRequest } from '../types/index.js';
|
||||
|
||||
export async function getHistoryEntries(req: AuthRequest, res: Response): Promise<void> {
|
||||
@@ -35,6 +36,12 @@ export async function createHistoryEntry(req: AuthRequest, res: Response): Promi
|
||||
createdBy: req.user?.email || 'unbekannt',
|
||||
});
|
||||
|
||||
await logChange({
|
||||
req, action: 'CREATE', resourceType: 'ContractHistory',
|
||||
resourceId: entry.id.toString(),
|
||||
label: `Historieneintrag "${title.trim()}" erstellt für Vertrag #${contractId}`,
|
||||
});
|
||||
|
||||
res.status(201).json({ success: true, data: entry } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
@@ -55,6 +62,12 @@ export async function updateHistoryEntry(req: AuthRequest, res: Response): Promi
|
||||
description: description?.trim(),
|
||||
});
|
||||
|
||||
await logChange({
|
||||
req, action: 'UPDATE', resourceType: 'ContractHistory',
|
||||
resourceId: entryId.toString(),
|
||||
label: `Historieneintrag aktualisiert für Vertrag #${contractId}`,
|
||||
});
|
||||
|
||||
res.json({ success: true, data: entry } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
@@ -71,6 +84,12 @@ export async function deleteHistoryEntry(req: AuthRequest, res: Response): Promi
|
||||
|
||||
await contractHistoryService.deleteHistoryEntry(contractId, entryId);
|
||||
|
||||
await logChange({
|
||||
req, action: 'DELETE', resourceType: 'ContractHistory',
|
||||
resourceId: entryId.toString(),
|
||||
label: `Historieneintrag gelöscht für Vertrag #${contractId}`,
|
||||
});
|
||||
|
||||
res.json({ success: true, message: 'Eintrag gelöscht' } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
|
||||
Reference in New Issue
Block a user