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:
28
Lambdas/Lists/List/src/ListAdder.java
Normal file
28
Lambdas/Lists/List/src/ListAdder.java
Normal file
@@ -0,0 +1,28 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ListAdder implements CallHandler {
|
||||
|
||||
private DBConnector connector;
|
||||
private String cognitoID;
|
||||
|
||||
private final String LIST_CREATE = "INSERT INTO Lists (Name, Owner) VALUES (?, ?)";
|
||||
|
||||
public ListAdder(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
|
||||
statement.setString(2, cognitoID);
|
||||
System.out.println(statement);
|
||||
statement.executeUpdate();
|
||||
connection.commit();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
11
Lambdas/Lists/List/src/ListPOST.java
Normal file
11
Lambdas/Lists/List/src/ListPOST.java
Normal file
@@ -0,0 +1,11 @@
|
||||
import java.util.Map;
|
||||
|
||||
import com.amazonaws.services.lambda.runtime.Context;
|
||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
||||
|
||||
public class ListPOST implements RequestHandler<Map<String,Object>, String>{
|
||||
|
||||
public String handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ListAdder.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user