Push non-completed code so I can move to my desktop!
This commit is contained in:
parent
2b57a5ef98
commit
39817d154c
@ -15,6 +15,7 @@ import net.frozenorb.apiv3.routes.grants.DELETEGrant;
|
||||
import net.frozenorb.apiv3.routes.grants.GETGrants;
|
||||
import net.frozenorb.apiv3.routes.grants.POSTUserGrant;
|
||||
import net.frozenorb.apiv3.routes.punishments.DELETEPunishment;
|
||||
import net.frozenorb.apiv3.routes.punishments.GETPunishment;
|
||||
import net.frozenorb.apiv3.routes.punishments.GETPunishments;
|
||||
import net.frozenorb.apiv3.routes.punishments.POSTUserPunish;
|
||||
import net.frozenorb.apiv3.routes.servers.GETServer;
|
||||
@ -72,8 +73,9 @@ public final class APIv3 {
|
||||
post("/user/:id:/grant", new POSTUserGrant(), gson::toJson);
|
||||
|
||||
delete("/punishment/:id", new DELETEPunishment(), gson::toJson);
|
||||
get("/punishment/:id", new GETPunishment(), gson::toJson);
|
||||
get("/punishments", new GETPunishments(), gson::toJson);
|
||||
post("/user/:id:/punish", new POSTUserPunish(), gson::toJson);
|
||||
post("/user/:id:/punish", new erPunish(), gson::toJson);
|
||||
|
||||
get("/server/:id", new GETServer(), gson::toJson);
|
||||
get("/servers", new GETServers(), gson::toJson);
|
||||
|
@ -0,0 +1,23 @@
|
||||
package net.frozenorb.apiv3.routes.grants;
|
||||
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.models.Grant;
|
||||
import net.frozenorb.apiv3.models.User;
|
||||
import net.frozenorb.apiv3.weirdStuff.ErrorUtils;
|
||||
import spark.Request;
|
||||
import spark.Response;
|
||||
import spark.Route;
|
||||
|
||||
public final class GETUserGrants implements Route {
|
||||
|
||||
public Object handle(Request req, Response res) {
|
||||
User target = User.byIdOrName(req.params("id"));
|
||||
|
||||
if (target == null) {
|
||||
return ErrorUtils.notFound("User", req.params("id"));
|
||||
}
|
||||
|
||||
return APIv3.getDatastore().createQuery(Grant.class).order("addedAt").limit(limit).offset(offset).asList();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package net.frozenorb.apiv3.routes.punishments;
|
||||
|
||||
import net.frozenorb.apiv3.models.Punishment;
|
||||
import net.frozenorb.apiv3.models.Server;
|
||||
import spark.Request;
|
||||
import spark.Response;
|
||||
import spark.Route;
|
||||
|
||||
public final class GETPunishment implements Route {
|
||||
|
||||
public Object handle(Request req, Response res) {
|
||||
return Punishment.byId(req.params("id"));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user