mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-10 18:55:03 +00:00
Finish V1 of List and Item Lambdas
List and Item Lambdas and client calls should be roughly finished (pending full testing once databse config is done).
This commit is contained in:
@@ -49,4 +49,76 @@ public class Item {
|
||||
", fetchCounts=" + fetchCounts +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getProductID() {
|
||||
return productID;
|
||||
}
|
||||
|
||||
public void setProductID(Integer productID) {
|
||||
this.productID = productID;
|
||||
}
|
||||
|
||||
public Integer getChainID() {
|
||||
return chainID;
|
||||
}
|
||||
|
||||
public void setChainID(Integer chainID) {
|
||||
this.chainID = chainID;
|
||||
}
|
||||
|
||||
public String getUpc() {
|
||||
return upc;
|
||||
}
|
||||
|
||||
public void setUpc(String upc) {
|
||||
this.upc = upc;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getImageURL() {
|
||||
return imageURL;
|
||||
}
|
||||
|
||||
public void setImageURL(String imageURL) {
|
||||
this.imageURL = imageURL;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public LocalDateTime getRetrievedDate() {
|
||||
return retrievedDate;
|
||||
}
|
||||
|
||||
public void setRetrievedDate(LocalDateTime retrievedDate) {
|
||||
this.retrievedDate = retrievedDate;
|
||||
}
|
||||
|
||||
public Integer getFetchCounts() {
|
||||
return fetchCounts;
|
||||
}
|
||||
|
||||
public void setFetchCounts(Integer fetchCounts) {
|
||||
this.fetchCounts = fetchCounts;
|
||||
}
|
||||
}
|
||||
|
||||
11
Lambdas/Lists/Item/src/ItemDELETE.java
Normal file
11
Lambdas/Lists/Item/src/ItemDELETE.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 ItemDELETE implements RequestHandler<Map<String,Object>, Object> {
|
||||
|
||||
public Object handleRequest(Map<String, Object> inputMap, Context unfilled) {
|
||||
return BasicHandler.handleRequest(inputMap, unfilled, ItemGetter.class);
|
||||
}
|
||||
}
|
||||
33
Lambdas/Lists/Item/src/ItemDeleter.java
Normal file
33
Lambdas/Lists/Item/src/ItemDeleter.java
Normal file
@@ -0,0 +1,33 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemDeleter implements CallHandler {
|
||||
|
||||
private DBConnector connector;
|
||||
private String cognitoID;
|
||||
|
||||
private final String REMOVE_FROM_LIST = "DELETE FROM ListProduct WHERE (ProductID = ? AND ListID = ?);";
|
||||
|
||||
public ItemDeleter(DBConnector connector, String cognitoID) {
|
||||
this.connector = connector;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
|
||||
Connection connection = connector.getConnection();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement(REMOVE_FROM_LIST);
|
||||
statement.setInt(1, (Integer) bodyMap.get("ProductID"));
|
||||
statement.setInt(2, (Integer) bodyMap.get("ListID"));
|
||||
System.out.println(statement);
|
||||
statement.executeUpdate();
|
||||
connection.commit();
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user