complete new audit system
This commit is contained in:
+19
-1
@@ -39,6 +39,7 @@ exports.createPlatform = createPlatform;
|
||||
exports.updatePlatform = updatePlatform;
|
||||
exports.deletePlatform = deletePlatform;
|
||||
const platformService = __importStar(require("../services/platform.service.js"));
|
||||
const audit_service_js_1 = require("../services/audit.service.js");
|
||||
async function getPlatforms(req, res) {
|
||||
try {
|
||||
const includeInactive = req.query.includeInactive === 'true';
|
||||
@@ -74,6 +75,11 @@ async function getPlatform(req, res) {
|
||||
async function createPlatform(req, res) {
|
||||
try {
|
||||
const platform = await platformService.createPlatform(req.body);
|
||||
await (0, audit_service_js_1.logChange)({
|
||||
req, action: 'CREATE', resourceType: 'Platform',
|
||||
resourceId: platform.id.toString(),
|
||||
label: `Vertriebsplattform ${platform.name} angelegt`,
|
||||
});
|
||||
res.status(201).json({ success: true, data: platform });
|
||||
}
|
||||
catch (error) {
|
||||
@@ -86,6 +92,11 @@ async function createPlatform(req, res) {
|
||||
async function updatePlatform(req, res) {
|
||||
try {
|
||||
const platform = await platformService.updatePlatform(parseInt(req.params.id), req.body);
|
||||
await (0, audit_service_js_1.logChange)({
|
||||
req, action: 'UPDATE', resourceType: 'Platform',
|
||||
resourceId: platform.id.toString(),
|
||||
label: `Vertriebsplattform ${platform.name} aktualisiert`,
|
||||
});
|
||||
res.json({ success: true, data: platform });
|
||||
}
|
||||
catch (error) {
|
||||
@@ -97,7 +108,14 @@ async function updatePlatform(req, res) {
|
||||
}
|
||||
async function deletePlatform(req, res) {
|
||||
try {
|
||||
await platformService.deletePlatform(parseInt(req.params.id));
|
||||
const platformId = parseInt(req.params.id);
|
||||
const platform = await platformService.getPlatformById(platformId);
|
||||
await platformService.deletePlatform(platformId);
|
||||
await (0, audit_service_js_1.logChange)({
|
||||
req, action: 'DELETE', resourceType: 'Platform',
|
||||
resourceId: platformId.toString(),
|
||||
label: `Vertriebsplattform ${platform?.name || platformId} gelöscht`,
|
||||
});
|
||||
res.json({ success: true, message: 'Vertriebsplattform gelöscht' });
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user