Browse Source

posgres support 4

master
gsd 6 months ago
parent
commit
6b260e7318
  1. 10
      src/main/java/app/services/db/DiscordAuthService.java

10
src/main/java/app/services/db/DiscordAuthService.java

@ -24,7 +24,7 @@ public class DiscordAuthService {
public SteamID getSteamIDofDiscordID(String discord_id) {
return jdbcTemplate.query("SELECT steam_id FROM steam2discord WHERE discord_id = ? AND active = 1 LIMIT 1",
new Object[]{ discord_id },
new Object[]{ Long.parseLong(discord_id) },
(rs, n) -> SteamIDConverter.getSteamID(rs.getString("steam_id")))
.stream().findFirst().orElse(null);
}
@ -32,13 +32,13 @@ public class DiscordAuthService {
public String getDiscordIDofSteamID(SteamID steamID) {
return jdbcTemplate.query("SELECT discord_id FROM steam2discord WHERE steam_id = ? AND active = 1 LIMIT 1",
new Object[]{ steamID.steam2 },
(rs, n) -> rs.getString("discord_id"))
.stream().findFirst().orElse(null);
(rs, n) -> rs.getLong("discord_id"))
.stream().map(Object::toString).findFirst().orElse(null);
}
public boolean setSteamIDofDiscordID(SteamID steamID, String discord_id) {
return jdbcTemplate.update("INSERT INTO steam2discord (steam_id, discord_id, timestamp, active) VALUES (?, ?, current_timestamp, 1)",
steamID.steam2, discord_id) > 0;
steamID.steam2, Long.parseLong(discord_id)) > 0;
}
public boolean removeSteamIDofDiscordID(SteamID steamID) {
@ -49,7 +49,7 @@ public class DiscordAuthService {
public List<String> getAccountsNotInList(List<String> discord_accounts) {
String inSql = String.join(",", Collections.nCopies(discord_accounts.size(), "?"));
return jdbcTemplate.query("SELECT discord_id FROM steam2discord WHERE active = 1 AND discord_id in (" + inSql + ")",
discord_accounts.toArray(),
discord_accounts.stream().mapToLong(Long::parseLong).mapToObj(x -> (Object) x).toArray(),
(rs, n) -> rs.getString("discord_id"));
}

Loading…
Cancel
Save