mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-10 18:55:03 +00:00
Switch to millis for times
There are issues with the serialization of the time objects since the constructors are not public. Passing times around in milliseconds avoid them.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class Item {
|
||||
Integer productID;
|
||||
@@ -11,7 +10,7 @@ public class Item {
|
||||
BigDecimal price;
|
||||
String imageURL;
|
||||
String department;
|
||||
LocalDateTime retrievedDate;
|
||||
long retrievedDate;
|
||||
Integer fetchCounts;
|
||||
|
||||
public Item(ResultSet itemRow) throws SQLException {
|
||||
@@ -29,7 +28,7 @@ public class Item {
|
||||
System.out.println(imageURL);
|
||||
this.department = itemRow.getString(7);
|
||||
System.out.println(department);
|
||||
this.retrievedDate = itemRow.getObject(8, LocalDateTime.class);
|
||||
this.retrievedDate = itemRow.getTimestamp(8).toInstant().toEpochMilli();
|
||||
System.out.println(retrievedDate);
|
||||
this.fetchCounts = itemRow.getInt(9);
|
||||
System.out.println(fetchCounts);
|
||||
@@ -106,11 +105,11 @@ public class Item {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public LocalDateTime getRetrievedDate() {
|
||||
public long getRetrievedDate() {
|
||||
return retrievedDate;
|
||||
}
|
||||
|
||||
public void setRetrievedDate(LocalDateTime retrievedDate) {
|
||||
public void setRetrievedDate(long retrievedDate) {
|
||||
this.retrievedDate = retrievedDate;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ public class ItemSearcher implements CallHandler {
|
||||
DBConnector connector;
|
||||
String cognitoID;
|
||||
|
||||
private final String GET_ITEM_MATCHES = "SELECT * FROM Product WHERE description LIKE %?%";
|
||||
private final String GET_ITEM_MATCHES = "SELECT * FROM Product WHERE description LIKE ?";
|
||||
|
||||
ItemSearcher(DBConnector connector, String cognitoID) {
|
||||
public ItemSearcher(DBConnector connector, String cognitoID) {
|
||||
this.connector = connector;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class ItemSearcher implements CallHandler {
|
||||
public Object conductAction(Map<String, Object> body, HashMap<String, String> queryParams, String s) throws SQLException {
|
||||
try (Connection connection = connector.getConnection()) {
|
||||
PreparedStatement getItemMatches = connection.prepareStatement(GET_ITEM_MATCHES);
|
||||
getItemMatches.setString(1, queryParams.get("id"));
|
||||
getItemMatches.setString(1, "%" + queryParams.get("id") + "%");
|
||||
System.out.println(getItemMatches);
|
||||
ResultSet searchResults = getItemMatches.executeQuery();
|
||||
ItemSearch searchResultsObject = new ItemSearch(searchResults);
|
||||
|
||||
@@ -6,13 +6,13 @@ public class ItemEntry {
|
||||
Integer listID;
|
||||
Integer productID;
|
||||
Integer quantity;
|
||||
LocalDateTime addedDate;
|
||||
long addedDate;
|
||||
Boolean purchased;
|
||||
public ItemEntry(Integer listID, ResultSet listRow) throws SQLException {
|
||||
this.listID = listID;
|
||||
productID = listRow.getInt(1);
|
||||
quantity = listRow.getInt(2);
|
||||
addedDate = listRow.getObject(3, LocalDateTime.class);
|
||||
addedDate = listRow.getTimestamp(3).toInstant().toEpochMilli();
|
||||
purchased = listRow.getBoolean(4);
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ public class ItemEntry {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public LocalDateTime getAddedDate() {
|
||||
public long getAddedDate() {
|
||||
return addedDate;
|
||||
}
|
||||
|
||||
public void setAddedDate(LocalDateTime addedDate) {
|
||||
public void setAddedDate(long addedDate) {
|
||||
this.addedDate = addedDate;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user