mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-10 18:55:03 +00:00
Generify endpoint groups as IntelliJ Modules
This allows them to be built sperately decreasing JAR size and also creates a better structure for generic service functions and business logic.
This commit is contained in:
27
Lambdas/Lists/Item/src/ItemAdder.java
Normal file
27
Lambdas/Lists/Item/src/ItemAdder.java
Normal file
@@ -0,0 +1,27 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemAdder implements CallHandler {
|
||||
|
||||
private DBConnector connector;
|
||||
private String cognitoID;
|
||||
|
||||
private final String LIST_CREATE = "INSERT INTO Items (Name) VALUES (?)";
|
||||
|
||||
public ItemAdder(DBConnector connector, String cognitoID) {
|
||||
this.connector = connector;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
public String conductAction(Map<String, Object> bodyMap, String queryString) throws SQLException {
|
||||
Connection connection = connector.getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(LIST_CREATE);
|
||||
statement.setString(1, bodyMap.get("name").toString());//Needs safe checking
|
||||
System.out.println(statement);
|
||||
statement.executeUpdate();
|
||||
connection.commit();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
11
Lambdas/Lists/Item/src/ItemGET.java
Normal file
11
Lambdas/Lists/Item/src/ItemGET.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 ItemGET implements RequestHandler<Map<String,Object>, String> {
|
||||
|
||||
public String handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ItemGetter.class);
|
||||
}
|
||||
}
|
||||
9
Lambdas/Lists/Item/src/ItemGetter.java
Normal file
9
Lambdas/Lists/Item/src/ItemGetter.java
Normal file
@@ -0,0 +1,9 @@
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemGetter implements CallHandler{
|
||||
@Override
|
||||
public String conductAction(Map<String, Object> bodyMap, String cognitoID) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
11
Lambdas/Lists/Item/src/ItemPOST.java
Normal file
11
Lambdas/Lists/Item/src/ItemPOST.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 ItemPOST implements RequestHandler<Map<String,Object>, String>{
|
||||
|
||||
public String handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ItemAdder.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user