Treat ListSharee as access table

This is so that multiple users can be paired with a single list.

In the future, we may want to reconsider list deletion behavior to simply remove a user's access and only delete it when no one has access.

We may also want the user deletion Lambda to use the list deletion Lambda when it is created.
This commit is contained in:
NMerz
2020-10-24 14:46:56 -04:00
parent 2637cab282
commit 34d74aae6a
6 changed files with 112 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ public class UserDeleter implements CallHandler {
private final String GET_LISTS = "SELECT * FROM List WHERE (owner = ?);";
private final String DELETE_LIST_PRODUCT = "DELETE FROM ListProduct WHERE (listID = ?);";
private final String DELETE_LISTS = "DELETE FROM List WHERE (owner = ?);";
private final String DELETE_LIST_SHARES = "DELETE FROM ListSharee WHERE (listID = ?);";
private final String DELETE_LIST_ACCESS = "DELETE FROM ListSharee WHERE (userID = ?);";
public UserDeleter(Connection connection, String cognitoID) {
this.connection = connection;
@@ -57,13 +59,23 @@ public class UserDeleter implements CallHandler {
statement = connection.prepareStatement(DELETE_LIST_PRODUCT);
statement.setInt(1, listID);
System.out.println(statement);
statement.executeQuery();
statement.executeUpdate();
statement = connection.prepareStatement(DELETE_LIST_SHARES);
statement.setInt(1, listID);
System.out.println(statement);
statement.executeUpdate();
}
statement = connection.prepareStatement(DELETE_LISTS);
statement.setString(1, cognitoID);
System.out.println(statement);
statement.executeQuery();
statement.executeUpdate();
statement = connection.prepareStatement(DELETE_LIST_ACCESS);
statement.setString(1, cognitoID);
System.out.println(statement);
statement.executeUpdate();
connection.commit();
return null;