Add: Lizenzpreise, Rollen-Picker, Audit-Log Fix, Ticket Benutzerfilter

This commit is contained in:
2026-06-03 09:29:30 +02:00
parent 222b9c6fc8
commit 859ab6b28d
7 changed files with 394 additions and 9 deletions

View File

@@ -15,6 +15,8 @@ const {
getConditionalAccessPolicies,
invalidateUserSessions,
} = require('../services/graph.service');
const Database = require('better-sqlite3');
const DB_PATH = process.env.DATABASE_PATH || './database.sqlite';
/**
* GET /api/entra/users
@@ -154,7 +156,28 @@ exports.getUserLicenses = async (req, res) => {
]);
const skuMap = {};
for (const s of skus) skuMap[s.skuId] = s;
const enriched = licenses.map(l => ({ ...l, skuInfo: skuMap[l.skuId] || null }));
// Preise aus license_prices Tabelle laden
let priceRows = [];
try {
const db = new Database(DB_PATH);
priceRows = db.prepare('SELECT sku_part_number, display_name, price_per_month FROM license_prices').all();
db.close();
} catch (_) {}
const enriched = licenses.map(l => {
const skuPart = l.skuPartNumber || '';
const skuPartUpper = skuPart.toUpperCase();
// Exact match zuerst, dann partial match
const priceRow = priceRows.find(p => p.sku_part_number.toUpperCase() === skuPartUpper)
|| priceRows.find(p => skuPartUpper.includes(p.sku_part_number.toUpperCase()) || p.sku_part_number.toUpperCase().includes(skuPartUpper));
return {
...l,
skuInfo: skuMap[l.skuId] || null,
price_per_month: priceRow?.price_per_month ?? null,
price_display_name: priceRow?.display_name ?? null,
};
});
res.json({ success: true, data: enriched });
} catch (e) {
res.status(500).json({ success: false, message: e.message });