added get endpoint for posts by id

This commit is contained in:
2024-05-25 15:47:14 +02:00
parent 5d494d0ad4
commit 4c1699c314
4 changed files with 148 additions and 31 deletions

View File

@@ -4,6 +4,8 @@ import java.util.Date;
import java.util.Optional;
import java.util.Vector;
import java.sql.*;
public class JodelPost {
// id of the post
public Long id;
@@ -24,7 +26,7 @@ public class JodelPost {
// the own reaction (null = none, true = positive, false = negative)
public Optional<Boolean> reaction;
// all other reactions
public Reaction reactions;
public Reactions reactions;
// anonymize function to recursively anonymize the posts
public void anonymize(Optional<Vector<Long>> idCache) {
@@ -70,8 +72,15 @@ public class JodelPost {
return false;
}
// constructor with private authorID
public JodelPost(long authorID) {
this.authorID = authorID;
// constructor from
public JodelPost(ResultSet rs) throws SQLException {
// add all other information to the post
this.authorID = rs.getLong("author");
this.id = rs.getLong("id");
this.title = rs.getString("title");
this.content = rs.getString("content");
this.date = rs.getDate("postdate");
this.location = new Location(rs.getLong("longitude"), rs.getLong("latitude"));
this.reactions = new Reactions(rs.getLong("positive"), rs.getLong("negative"));
}
}