mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Add chain id list retrieval
Update ChainGetter to work with getListOfIds
This commit is contained in:
parent
2d3e985ded
commit
f8db33bde4
@ -2,6 +2,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -9,6 +10,7 @@ public class ChainGetter implements CallHandler {
|
||||
private final Connection connection;
|
||||
|
||||
private final String GET_CHAIN = "SELECT * FROM Chain WHERE chainID = ?;";
|
||||
private final String GET_CHAINS = "SELECT chainID FROM Chain;";
|
||||
|
||||
public ChainGetter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
@ -16,8 +18,21 @@ public class ChainGetter implements CallHandler {
|
||||
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
Integer id = Integer.parseInt(queryMap.get("id"));
|
||||
if (id == -1) {
|
||||
PreparedStatement getChains = connection.prepareStatement(GET_CHAINS);
|
||||
System.out.println(getChains);
|
||||
ResultSet getChainsResults = getChains.executeQuery();
|
||||
System.out.println(getChainsResults);
|
||||
ArrayList<Integer> chainIDs = new ArrayList<>();
|
||||
while (getChainsResults.next()) {
|
||||
chainIDs.add(getChainsResults.getInt("chainID"));
|
||||
}
|
||||
return chainIDs;
|
||||
}
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(GET_CHAIN);
|
||||
statement.setInt(1, Integer.parseInt(queryMap.get("id")));
|
||||
statement.setInt(1, id);
|
||||
System.out.println(statement);
|
||||
ResultSet queryResults = statement.executeQuery();
|
||||
queryResults.first();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user