implemented download of account data as CSV
Build Docker Image / Docker-Build (push) Successful in 2m4s
Build Docker Image / Clean-Registry (push) Successful in 6s

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-08-16 23:08:51 +02:00
parent 695c1e769f
commit 94f11ea38f
5 changed files with 78 additions and 19 deletions
@@ -78,7 +78,7 @@ public class AccountingModule extends BaseHandler implements AccountingService {
case null -> getAccounts(user.get(),ex);
default -> {
try {
yield getAccount(user.get(),Long.parseLong(head),ex);
yield getAccount(user.get(),Long.parseLong(head), path.pop(), ex);
} catch (NumberFormatException ignored) {}
yield super.doGet(path,ex);
}
@@ -184,9 +184,17 @@ public class AccountingModule extends BaseHandler implements AccountingService {
return null;
}
private boolean getAccount(UmbrellaUser user, long accountId, HttpExchange ex) throws IOException {
private boolean getAccount(UmbrellaUser user, long accountId, String format, HttpExchange ex) throws IOException {
if (!accountDb.getMembers(accountId).contains(user)) throw forbidden("You are not allowed to access account {id}",Field.ID,accountId);
return sendContent(ex, loadAccount(accountId));
var data = loadAccount(accountId);
return switch (format){
case "csv" -> {
ex.getResponseHeaders().add("Content-Type", "text/csv");
var users = userService().loader();
yield sendContent(ex,data.toCsv(users));
}
case null, default -> sendContent(ex,data);
};
}
private boolean getAccounts(UmbrellaUser user, HttpExchange ex) throws IOException {