added user reaction

This commit is contained in:
2024-06-11 12:41:14 +02:00
parent 018285c109
commit ded34c5f43
2 changed files with 9 additions and 7 deletions

View File

@@ -75,10 +75,11 @@ public class Routes {
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
inner join targets ON targets.id = com.parent
)
SELECT * FROM targets;""");
SELECT targets.*, reactions.positive AS reaction FROM targets, reactions WHERE targets.id = reactions.post AND reactions.userid = (?);""");
stmt.setObject(1, longitude);
stmt.setObject(2, latitude);
stmt.setObject(3, User.getUserID());
// query recursively for posts inside a 10km radius
ResultSet rs = stmt.executeQuery();
@@ -179,9 +180,10 @@ public class Routes {
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
inner join targets ON targets.id = com.parent
)
SELECT * FROM targets;""");
SELECT targets.*, reactions.positive AS reaction FROM targets, reactions WHERE targets.id = reactions.post AND reactions.userid = (?);""");
stmt.setObject(1, id);
stmt.setObject(2, User.getUserID());
// query recursively for posts inside a 10km radius
ResultSet rs = stmt.executeQuery();
@@ -320,9 +322,10 @@ public class Routes {
c.setAutoCommit(false);
// create a new statement
stmt = c.prepareStatement("UPDATE Posts SET deleted = now() WHERE id = ? AND deleted IS NULL");
stmt = c.prepareStatement("UPDATE Posts SET deleted = now() WHERE id = ? AND author = (?) AND deleted IS NULL");
stmt.setObject(1, id);
stmt.setObject(2, User.getUserID());
// insert delete time
stmt.execute();