Browse Source

banlist 2

master
gsd 1 year ago
parent
commit
7261f77b27
  1. 10
      src/main/java/app/entities/db/Ban.java
  2. 8
      src/main/java/app/services/db/BanService.java

10
src/main/java/app/entities/db/Ban.java

@ -1,6 +1,7 @@
package app.entities.db;
import app.entities.other.SteamID;
import app.services.db.PermitionService;
import app.utils.CryptedCookie;
import app.utils.SteamIDConverter;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -25,6 +26,7 @@ public class Ban {
String unbanned_by_id;
Timestamp unbanned_timestamp;
AdminInfo admin_info;
AdminInfo unbanned_admin_info;
public Ban(Object[] obj) {
id = (int) obj[0];
@ -51,7 +53,11 @@ public class Ban {
}
@JsonIgnore
public SteamID getModeration() {
return SteamIDConverter.getSteamID(banned_by_id);
public void fillAdmins(PermitionService permitionService) {
setAdmin_info(permitionService.getAdminInfo(SteamIDConverter.getSteamID(banned_by_id)));
if (!active) {
if (unbanned_by_id == null || unbanned_by_id.isEmpty() || unbanned_by_id.equals("STEAM_0:0:0")) {}
else setUnbanned_admin_info(permitionService.getAdminInfo(SteamIDConverter.getSteamID(unbanned_by_id)));
}
}
}

8
src/main/java/app/services/db/BanService.java

@ -38,7 +38,7 @@ public class BanService {
.getResultList();
return result.stream().map(Ban::new)
.peek(ban -> ban.cryptIP(cryptedCookie))
.peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration())))
.peek(ban -> ban.fillAdmins(permitionService))
.findFirst()
.orElse(null);
}
@ -49,7 +49,7 @@ public class BanService {
.getResultList();
return result.stream().map(Ban::new)
.peek(ban -> ban.cryptIP(cryptedCookie))
.peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration())))
.peek(ban -> ban.fillAdmins(permitionService))
.findFirst()
.orElse(null);
}
@ -60,7 +60,7 @@ public class BanService {
.getResultList();
return result.stream().map(Ban::new)
.peek(ban -> ban.cryptIP(cryptedCookie))
.peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration())))
.peek(ban -> ban.fillAdmins(permitionService))
.toList();
}
@ -70,7 +70,7 @@ public class BanService {
.setParameter(2, limit)
.getResultStream().map(obj -> new Ban((Object[]) obj)).toList()).stream()
.peek(ban -> ban.cryptIP(cryptedCookie))
.peek(ban -> ban.setAdmin_info(permitionService.getAdminInfo(ban.getModeration())))
.peek(ban -> ban.fillAdmins(permitionService))
.toList();
//этот каст конечно пиздец, но он работает
}

Loading…
Cancel
Save