Add the ability to specify the punisher as a parameter in the GET punishments route
This commit is contained in:
parent
d90981bdec
commit
e14ea127cb
@ -48,7 +48,11 @@ public final class Punishment {
|
||||
punishmentsCollection.find(new Document("type", new Document("$in", convertedTypes))).into(new LinkedList<>(), SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
public static void findPaginated(Document query, int skip, int pageSize, SingleResultCallback<List<Punishment>> callback) {
|
||||
public static void findPaginated(Document query, int skip, int pageSize, UUID addedBy, SingleResultCallback<List<Punishment>> callback) {
|
||||
if (addedBy != null) {
|
||||
query.put("addedBy", addedBy);
|
||||
}
|
||||
|
||||
punishmentsCollection.find(query).sort(new Document("addedAt", -1)).skip(skip).limit(pageSize).into(new LinkedList<>(), SyncUtils.vertxWrap(callback));
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import net.frozenorb.apiv3.util.ErrorUtils;
|
||||
import net.frozenorb.apiv3.util.UuidUtils;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class GETPunishments implements Handler<RoutingContext> {
|
||||
@ -16,8 +17,9 @@ public final class GETPunishments implements Handler<RoutingContext> {
|
||||
try {
|
||||
int skip = ctx.request().getParam("skip") == null ? 0 : Integer.parseInt(ctx.request().getParam("skip"));
|
||||
int pageSize = ctx.request().getParam("pageSize") == null ? 100 : Integer.parseInt(ctx.request().getParam("pageSize"));
|
||||
UUID addedBy = ctx.request().getParam("addedBy") == null ? null : UUID.fromString(ctx.request().getParam("addedBy"));
|
||||
|
||||
Punishment.findPaginated(ctx.request().getParam("user") == null ? new Document() : new Document("user", UuidUtils.parseUuid(ctx.request().getParam("user"))), skip, pageSize, (punishments, error) -> {
|
||||
Punishment.findPaginated(ctx.request().getParam("user") == null ? new Document() : new Document("user", UuidUtils.parseUuid(ctx.request().getParam("user"))), skip, pageSize, addedBy, (punishments, error) -> {
|
||||
if (error != null) {
|
||||
ErrorUtils.respondInternalError(ctx, error);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user