add restaurants check connection
This commit is contained in:
@@ -22,6 +22,7 @@ import su.xserver.iikocon.handler.AdminHandler;
|
||||
import su.xserver.iikocon.handler.AuthHandler;
|
||||
import su.xserver.iikocon.handler.SecurityHandler;
|
||||
import su.xserver.iikocon.handler.SetupHandler;
|
||||
import su.xserver.iikocon.iiko.IikoOlapClient;
|
||||
import su.xserver.iikocon.service.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -350,6 +351,24 @@ public class MainVerticle extends AbstractVerticle {
|
||||
.onFailure(err -> rc.response().setStatusCode(500).end(err.getMessage()));
|
||||
});
|
||||
|
||||
router.get("/api/admin/restaurants/:id/check").handler(rc -> {
|
||||
int id = Integer.parseInt(rc.pathParam("id"));
|
||||
restaurantService.findById(id)
|
||||
.onSuccess(rest -> {
|
||||
if (rest == null) {
|
||||
rc.response().setStatusCode(404).end();
|
||||
} else {
|
||||
IikoOlapClient iiko = new IikoOlapClient(vertx, rest);
|
||||
|
||||
iiko.checkConnection()
|
||||
.onSuccess(res -> rc.response().putHeader("Content-Type", "application/json").end(res.encode()))
|
||||
.onFailure(err -> rc.response().putHeader("Content-Type", "application/json").end(
|
||||
new JsonObject().put("success", false).put("error", err.getMessage()).encode()));
|
||||
}
|
||||
})
|
||||
.onFailure(err -> rc.response().setStatusCode(500).end(err.getMessage()));
|
||||
});
|
||||
|
||||
router.post("/api/admin/restaurants").handler(rc -> {
|
||||
JsonObject body = rc.body().asJsonObject();
|
||||
String name = body.getString("name");
|
||||
|
||||
Reference in New Issue
Block a user