From b58044e8219e44ec26e1887bcfd79e554f4b4824 Mon Sep 17 00:00:00 2001 From: gsd Date: Sun, 12 Feb 2023 19:59:29 +0300 Subject: [PATCH] Ban history --- src/main/java/app/services/db/BanService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/app/services/db/BanService.java b/src/main/java/app/services/db/BanService.java index 48fb833..0ba1771 100644 --- a/src/main/java/app/services/db/BanService.java +++ b/src/main/java/app/services/db/BanService.java @@ -32,6 +32,17 @@ public class BanService { return result.stream().map(Ban::new).findFirst().orElse(null); } + public List getBans(SteamID steamID) { + List result = entityManager.createNativeQuery("SELECT * FROM light_bans WHERE account_id = ?1 AND active = 0") + .setParameter(1, steamID.account_id) + .getResultList(); + return result.stream().map(Ban::new).toList(); + } + + public Long getBansCount(SteamID steamID) { + return (Long) entityManager.createNativeQuery("SELECT COUNT(*) FROM light_bans WHERE account_id = ?1 AND active = 0").getSingleResult(); + } + @Transactional public boolean removeBan(PlayerProfile user, PlayerProfile admin) { Ban ban = getBan(user.getSteamids());