mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 02:38:47 +00:00
Merge pull request #81 from ClaytonWWilson/list-share-lambda
Correct shareWithEmail naming
This commit is contained in:
commit
567f0ccc00
@ -8,13 +8,15 @@ public class List {
|
||||
String owner;
|
||||
long lastUpdated;
|
||||
ArrayList<ItemEntry> entries;
|
||||
boolean shared;
|
||||
|
||||
public List(ResultSet listRow) throws SQLException {
|
||||
public List(ResultSet listRow, boolean shared) throws SQLException {
|
||||
itemID = listRow.getInt("listID");
|
||||
name = listRow.getString("name");
|
||||
owner = listRow.getString("owner");
|
||||
lastUpdated = listRow.getTimestamp("lastUpdated").toInstant().toEpochMilli();
|
||||
entries = new ArrayList<>();
|
||||
this.shared = shared;
|
||||
}
|
||||
|
||||
public void addItemEntry(ItemEntry entry) {
|
||||
@ -67,4 +69,12 @@ public class List {
|
||||
public void setLastUpdated(long lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
public boolean getShared() {
|
||||
return shared;
|
||||
}
|
||||
|
||||
public void setShared(boolean shared) {
|
||||
this.shared = shared;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ public class ListGetter implements CallHandler{
|
||||
|
||||
private final String GET_LIST = "SELECT * FROM List WHERE listID = ?;";
|
||||
private final String GET_LISTS = "SELECT listID FROM ListSharee WHERE userID = ?;";
|
||||
private final String SHARE_CHECK = "SELECT * FROM ListSharee WHERE listID = ?;";
|
||||
private final String GET_ENTRIES = "SELECT * FROM ListProduct WHERE listID = ?;";
|
||||
|
||||
public ListGetter(Connection connection, String cognitoID) {
|
||||
@ -34,13 +35,25 @@ public class ListGetter implements CallHandler{
|
||||
}
|
||||
return listIds;
|
||||
}
|
||||
PreparedStatement checkAccess = connection.prepareStatement(SHARE_CHECK);
|
||||
checkAccess.setInt(1, id);
|
||||
System.out.println(checkAccess);
|
||||
ResultSet accessResults = checkAccess.executeQuery();
|
||||
int sharees = 0;
|
||||
while (sharees < 2 && accessResults.next()) {
|
||||
sharees++;
|
||||
}
|
||||
boolean shared = false;
|
||||
if (sharees > 1) {
|
||||
shared = true;
|
||||
}
|
||||
PreparedStatement getList = connection.prepareStatement(GET_LIST);
|
||||
getList.setInt(1, id);
|
||||
System.out.println(getList);
|
||||
ResultSet getListResults = getList.executeQuery();
|
||||
getListResults.first();
|
||||
System.out.println(getListResults);
|
||||
List retrievedList = new List(getListResults);
|
||||
List retrievedList = new List(getListResults, shared);
|
||||
System.out.println(retrievedList);
|
||||
PreparedStatement getListEntries = connection.prepareStatement(GET_ENTRIES);
|
||||
getListEntries.setInt(1, id);
|
||||
|
||||
@ -37,7 +37,7 @@ public class ListSharer implements CallHandler {
|
||||
invokeRequest.setFunctionName("UserGET");
|
||||
invokeRequest.setPayload("{" +
|
||||
" \"body\": {" +
|
||||
" \"emailToCheck\": \"" + bodyMap.get("shareWith").toString() + "\"" +
|
||||
" \"emailToCheck\": \"" + bodyMap.get("shareWithEmail").toString() + "\"" +
|
||||
" }," +
|
||||
" \"params\": {" +
|
||||
" \"querystring\": {" +
|
||||
|
||||
@ -8,17 +8,19 @@ public class List {
|
||||
String owner;
|
||||
long lastUpdated;
|
||||
final ListEntry[] entries;
|
||||
boolean shared;
|
||||
|
||||
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries) {
|
||||
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared) {
|
||||
this.itemID = itemID;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.lastUpdated = lastUpdated;
|
||||
this.entries = entries;
|
||||
this.shared = false;
|
||||
}
|
||||
|
||||
public List(Integer itemID, String name, String owner, long lastUpdated) {
|
||||
this(itemID, name, owner, lastUpdated, null);
|
||||
this(itemID, name, owner, lastUpdated, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,6 +31,7 @@ public class List {
|
||||
", owner='" + owner + '\'' +
|
||||
", lastUpdated=" + lastUpdated +
|
||||
", entries=" + Arrays.toString(entries) +
|
||||
", shared=" + shared +
|
||||
'}';
|
||||
}
|
||||
|
||||
@ -67,4 +70,12 @@ public class List {
|
||||
public ListEntry[] getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public boolean isShared() {
|
||||
return shared;
|
||||
}
|
||||
|
||||
public void setShared(boolean shared) {
|
||||
this.shared = shared;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user