mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Merge pull request #96 from ClaytonWWilson/chain-get
Add chainID to Chain class Lambda
This commit is contained in:
commit
a355820c3c
35
Lambdas/Lists/Chain/src/Chain.java
Normal file
35
Lambdas/Lists/Chain/src/Chain.java
Normal file
@ -0,0 +1,35 @@
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Chain {
|
||||
String name;
|
||||
String website;
|
||||
|
||||
public Chain (ResultSet chainRow) throws SQLException {
|
||||
this.name = chainRow.getString("name");
|
||||
System.out.println(this.name);
|
||||
this.website = chainRow.getString("website");
|
||||
System.out.println(this.website);
|
||||
}
|
||||
|
||||
public Chain(String name, String website) {
|
||||
this.name = name;
|
||||
this.website = website;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
}
|
||||
11
Lambdas/Lists/Chain/src/ChainGET.java
Normal file
11
Lambdas/Lists/Chain/src/ChainGET.java
Normal file
@ -0,0 +1,11 @@
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ChainGET implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ChainGetter.class);
|
||||
}
|
||||
}
|
||||
29
Lambdas/Lists/Chain/src/ChainGetter.java
Normal file
29
Lambdas/Lists/Chain/src/ChainGetter.java
Normal file
@ -0,0 +1,29 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChainGetter implements CallHandler {
|
||||
private final Connection connection;
|
||||
|
||||
private final String GET_CHAIN = "SELECT * FROM Chain WHERE chainID = ?;";
|
||||
|
||||
public ChainGetter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
PreparedStatement statement = connection.prepareStatement(GET_CHAIN);
|
||||
statement.setInt(1, Integer.parseInt(queryMap.get("id")));
|
||||
System.out.println(statement);
|
||||
ResultSet queryResults = statement.executeQuery();
|
||||
queryResults.first();
|
||||
System.out.println(queryResults);
|
||||
Chain retrievedChain = new Chain(queryResults);
|
||||
System.out.println(retrievedChain);
|
||||
return retrievedChain;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.example.listify.data;
|
||||
|
||||
public class Chain {
|
||||
String name;
|
||||
String website;
|
||||
|
||||
public Chain(String name, String website) {
|
||||
this.name = name;
|
||||
this.website = website;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user