SHA256
UI и API: экран серверов доступа и фильтр SearchUsers
This commit is contained in:
@@ -154,6 +154,11 @@ public final class CurrentUsersDAO {
|
||||
|
||||
/** Поиск по префиксу с внешним соединением. Соединение НЕ закрывает. */
|
||||
public List<CurrentUserEntry> searchByLoginPrefix(Connection c, String prefix) throws SQLException {
|
||||
return searchByLoginPrefix(c, prefix, null);
|
||||
}
|
||||
|
||||
/** Поиск по префиксу с optional-фильтром server PDA. Соединение НЕ закрывает. */
|
||||
public List<CurrentUserEntry> searchByLoginPrefix(Connection c, String prefix, Boolean isServer) throws SQLException {
|
||||
String sql = """
|
||||
SELECT
|
||||
login,
|
||||
@@ -163,6 +168,7 @@ public final class CurrentUsersDAO {
|
||||
client_key
|
||||
FROM %s
|
||||
WHERE LOWER(login) LIKE ?
|
||||
AND (? IS NULL OR is_server = ?)
|
||||
ORDER BY login
|
||||
LIMIT 5
|
||||
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||
@@ -171,6 +177,13 @@ public final class CurrentUsersDAO {
|
||||
|
||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||
ps.setString(1, prefix.toLowerCase() + "%");
|
||||
if (isServer == null) {
|
||||
ps.setNull(2, Types.BOOLEAN);
|
||||
ps.setNull(3, Types.BOOLEAN);
|
||||
} else {
|
||||
ps.setBoolean(2, isServer);
|
||||
ps.setBoolean(3, isServer);
|
||||
}
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) result.add(mapRow(rs));
|
||||
}
|
||||
@@ -181,8 +194,13 @@ public final class CurrentUsersDAO {
|
||||
|
||||
/** Поиск по префиксу без внешнего соединения. Сам открывает/закрывает. */
|
||||
public List<CurrentUserEntry> searchByLoginPrefix(String prefix) throws SQLException {
|
||||
return searchByLoginPrefix(prefix, null);
|
||||
}
|
||||
|
||||
/** Поиск по префиксу без внешнего соединения с optional-фильтром server PDA. */
|
||||
public List<CurrentUserEntry> searchByLoginPrefix(String prefix, Boolean isServer) throws SQLException {
|
||||
try (Connection c = db.getConnection()) {
|
||||
return searchByLoginPrefix(c, prefix);
|
||||
return searchByLoginPrefix(c, prefix, isServer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public final class CurrentUsersSql {
|
||||
current_users.blockchain_name AS blockchain_name,
|
||||
current_users.client_key AS solana_key,
|
||||
current_users.blockchain_key AS blockchain_key,
|
||||
current_users.client_key AS client_key
|
||||
current_users.client_key AS client_key,
|
||||
current_users.is_server AS is_server
|
||||
FROM solana_user_pda_current current_users
|
||||
) %s
|
||||
""".formatted(alias);
|
||||
|
||||
Reference in New Issue
Block a user