Browse Source

admin info to ban

master
gsd 2 years ago
parent
commit
84edecd0f1
  1. 29
      src/main/java/app/entities/db/AdminInfo.java
  2. 1
      src/main/java/app/entities/db/Ban.java
  3. 5
      src/main/java/app/services/ProfileService.java
  4. 8
      src/main/java/app/services/db/PermitionService.java

29
src/main/java/app/entities/db/AdminInfo.java

@ -0,0 +1,29 @@
package app.entities.db;
import app.utils.SteamIDConverter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
@Data
public class AdminInfo {
@JsonIgnore
int id;
int vk_id;
long discord_id;
String discord_name;
@JsonIgnore
String steam3;
String steam_url;
@JsonIgnore
int permition;
public AdminInfo(Object[] obj) {
id = (int) obj[0];
vk_id = (int) obj[1];
discord_id = (long) obj[2];
discord_name = (String) obj[3];
steam3 = (String) obj[4];
permition = (int) obj[5];
steam_url = SteamIDConverter.getSteamID(steam3).community_url;
}
}

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

@ -24,6 +24,7 @@ public class Ban {
boolean active;
String unbanned_by_id;
Timestamp unbanned_timestamp;
AdminInfo admin_info;
public Ban(Object[] obj) {
id = (int) obj[0];

5
src/main/java/app/services/ProfileService.java

@ -88,6 +88,11 @@ public class ProfileService {
//if(requests.contains("ban")){
start_time = Instant.now().toEpochMilli();
profile.setBan(banService.getBan(steamID));
if(profile.getBan() != null) {
profile.getBan().setAdmin_info(
permitionService.getAdminInfo(SteamIDConverter.getSteamID(profile.getBan().getBanned_by_id()))
);
}
end_time = Instant.now().toEpochMilli() - start_time;
profile.getResponse_time().put("ban", Double.valueOf(end_time) / 1000);
//}

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

@ -1,5 +1,6 @@
package app.services.db;
import app.entities.db.AdminInfo;
import app.entities.db.Ban;
import app.entities.db.Permition;
import app.entities.other.SteamID;
@ -65,4 +66,11 @@ public class PermitionService {
if (getPermition(steamID) == null) return true;
return removePermition(steamID, "VIP");
}
public AdminInfo getAdminInfo(SteamID steamID) {
List<Object[]> result = entityManager.createNativeQuery("SELECT id, vk_id, discord_id, discord_name, steam3, permition FROM bot_admins WHERE steam3 LIKE ?1")
.setParameter(1, steamID.steam3)
.getResultList();
return result.stream().map(AdminInfo::new).findFirst().orElse(null);
}
}

Loading…
Cancel
Save