complete new audit system
This commit is contained in:
+19
-1
@@ -39,6 +39,7 @@ exports.createCancellationPeriod = createCancellationPeriod;
|
||||
exports.updateCancellationPeriod = updateCancellationPeriod;
|
||||
exports.deleteCancellationPeriod = deleteCancellationPeriod;
|
||||
const cancellationPeriodService = __importStar(require("../services/cancellation-period.service.js"));
|
||||
const audit_service_js_1 = require("../services/audit.service.js");
|
||||
async function getCancellationPeriods(req, res) {
|
||||
try {
|
||||
const includeInactive = req.query.includeInactive === 'true';
|
||||
@@ -74,6 +75,11 @@ async function getCancellationPeriod(req, res) {
|
||||
async function createCancellationPeriod(req, res) {
|
||||
try {
|
||||
const period = await cancellationPeriodService.createCancellationPeriod(req.body);
|
||||
await (0, audit_service_js_1.logChange)({
|
||||
req, action: 'CREATE', resourceType: 'CancellationPeriod',
|
||||
resourceId: period.id.toString(),
|
||||
label: `Kündigungsfrist ${period.description} angelegt`,
|
||||
});
|
||||
res.status(201).json({ success: true, data: period });
|
||||
}
|
||||
catch (error) {
|
||||
@@ -86,6 +92,11 @@ async function createCancellationPeriod(req, res) {
|
||||
async function updateCancellationPeriod(req, res) {
|
||||
try {
|
||||
const period = await cancellationPeriodService.updateCancellationPeriod(parseInt(req.params.id), req.body);
|
||||
await (0, audit_service_js_1.logChange)({
|
||||
req, action: 'UPDATE', resourceType: 'CancellationPeriod',
|
||||
resourceId: period.id.toString(),
|
||||
label: `Kündigungsfrist ${period.description} aktualisiert`,
|
||||
});
|
||||
res.json({ success: true, data: period });
|
||||
}
|
||||
catch (error) {
|
||||
@@ -97,7 +108,14 @@ async function updateCancellationPeriod(req, res) {
|
||||
}
|
||||
async function deleteCancellationPeriod(req, res) {
|
||||
try {
|
||||
await cancellationPeriodService.deleteCancellationPeriod(parseInt(req.params.id));
|
||||
const periodId = parseInt(req.params.id);
|
||||
const period = await cancellationPeriodService.getCancellationPeriodById(periodId);
|
||||
await cancellationPeriodService.deleteCancellationPeriod(periodId);
|
||||
await (0, audit_service_js_1.logChange)({
|
||||
req, action: 'DELETE', resourceType: 'CancellationPeriod',
|
||||
resourceId: periodId.toString(),
|
||||
label: `Kündigungsfrist ${period?.description || periodId} gelöscht`,
|
||||
});
|
||||
res.json({ success: true, message: 'Kündigungsfrist gelöscht' });
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user