added user reaction
This commit is contained in:
@@ -88,6 +88,7 @@ public class JodelPost {
|
|||||||
this.content = rs.getString("content");
|
this.content = rs.getString("content");
|
||||||
this.date = rs.getTimestamp("postdate");
|
this.date = rs.getTimestamp("postdate");
|
||||||
this.location = new Location(rs.getFloat("longitude"), rs.getFloat("latitude"));
|
this.location = new Location(rs.getFloat("longitude"), rs.getFloat("latitude"));
|
||||||
|
this.reaction = Optional.of(rs.getBoolean("reaction"));
|
||||||
this.reactions = new Reactions(rs.getLong("positive"), rs.getLong("negative"));
|
this.reactions = new Reactions(rs.getLong("positive"), rs.getLong("negative"));
|
||||||
this.parent = Optional.of(rs.getLong("parent"));
|
this.parent = Optional.of(rs.getLong("parent"));
|
||||||
}
|
}
|
||||||
@@ -102,10 +103,8 @@ public class JodelPost {
|
|||||||
@JsonProperty("content") String content,
|
@JsonProperty("content") String content,
|
||||||
@JsonProperty("date") Timestamp date,
|
@JsonProperty("date") Timestamp date,
|
||||||
@JsonProperty("location") Location location,
|
@JsonProperty("location") Location location,
|
||||||
@JsonProperty("parent") Optional<Long> parent,
|
@JsonProperty("parent") Optional<Long> parent) {
|
||||||
// TODO: getter from Keycloak
|
this.authorID = User.getUserID(); // TODO: getter from Keycloak
|
||||||
@JsonProperty("authorID") long author) {
|
|
||||||
this.authorID = author; // TODO: getter from Keycloak
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.date = date;
|
this.date = date;
|
||||||
|
|||||||
@@ -75,10 +75,11 @@ public class Routes {
|
|||||||
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
|
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
|
||||||
inner join targets ON targets.id = com.parent
|
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(1, longitude);
|
||||||
stmt.setObject(2, latitude);
|
stmt.setObject(2, latitude);
|
||||||
|
stmt.setObject(3, User.getUserID());
|
||||||
|
|
||||||
// query recursively for posts inside a 10km radius
|
// query recursively for posts inside a 10km radius
|
||||||
ResultSet rs = stmt.executeQuery();
|
ResultSet rs = stmt.executeQuery();
|
||||||
@@ -179,9 +180,10 @@ public class Routes {
|
|||||||
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
|
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
|
||||||
inner join targets ON targets.id = com.parent
|
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(1, id);
|
||||||
|
stmt.setObject(2, User.getUserID());
|
||||||
|
|
||||||
// query recursively for posts inside a 10km radius
|
// query recursively for posts inside a 10km radius
|
||||||
ResultSet rs = stmt.executeQuery();
|
ResultSet rs = stmt.executeQuery();
|
||||||
@@ -320,9 +322,10 @@ public class Routes {
|
|||||||
c.setAutoCommit(false);
|
c.setAutoCommit(false);
|
||||||
|
|
||||||
// create a new statement
|
// 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(1, id);
|
||||||
|
stmt.setObject(2, User.getUserID());
|
||||||
|
|
||||||
// insert delete time
|
// insert delete time
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
|
|||||||
Reference in New Issue
Block a user