eat(ausruestung): allow create role to view full list, add Mitglieder pagination, add admin reset for persoenliche Ausruestung

This commit is contained in:
Matthias Hochmeister
2026-04-16 07:52:36 +02:00
parent 3f8c4d151d
commit dac0b79b3b
7 changed files with 46 additions and 11 deletions

View File

@@ -238,6 +238,21 @@ class CleanupService {
logger.info(`Cleanup: truncated buchhaltung_bankkonten (${count} rows) and reset sequence`);
return { count, deleted: true };
}
async resetPersoenlicheAusruestung(confirm: boolean): Promise<CleanupResult> {
if (!confirm) {
const { rows } = await pool.query('SELECT COUNT(*)::int AS count FROM persoenliche_ausruestung WHERE geloescht_am IS NULL');
return { count: rows[0].count, deleted: false };
}
const { rows } = await pool.query('SELECT COUNT(*)::int AS count FROM persoenliche_ausruestung');
const count = rows[0].count;
// Clear FK references from request positions before truncating
await pool.query(`UPDATE ausruestung_anfrage_positionen SET zuweisung_persoenlich_id = NULL, zuweisung_typ = 'keine' WHERE zuweisung_persoenlich_id IS NOT NULL`);
// CASCADE removes persoenliche_ausruestung_eigenschaften rows automatically
await pool.query('TRUNCATE persoenliche_ausruestung CASCADE');
logger.info(`Cleanup: truncated persoenliche_ausruestung (${count} rows)`);
return { count, deleted: true };
}
}
export default new CleanupService();