generate crud for models
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.infinimotion</groupId>
|
<groupId>de.infinimotion</groupId>
|
||||||
<artifactId>model-backend</artifactId>
|
<artifactId>model-backend</artifactId>
|
||||||
<version>0.0.56</version>
|
<version>0.0.64</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Quarkus -->
|
<!-- Quarkus -->
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.infinimotion.backend;
|
|||||||
|
|
||||||
import de.infinimotion.model.backend.CommandException;
|
import de.infinimotion.model.backend.CommandException;
|
||||||
import de.infinimotion.model.backend.CommandWrapper;
|
import de.infinimotion.model.backend.CommandWrapper;
|
||||||
|
import de.infinimotion.model.backend.RequestReply;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import org.eclipse.microprofile.reactive.messaging.Channel;
|
import org.eclipse.microprofile.reactive.messaging.Channel;
|
||||||
import org.eclipse.microprofile.reactive.messaging.Emitter;
|
import org.eclipse.microprofile.reactive.messaging.Emitter;
|
||||||
@@ -15,7 +16,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class BetterRequestReply {
|
public class BetterRequestReply implements RequestReply {
|
||||||
|
|
||||||
@Channel("command")
|
@Channel("command")
|
||||||
Emitter<CommandWrapper> emitter;
|
Emitter<CommandWrapper> emitter;
|
||||||
@@ -35,7 +36,8 @@ public class BetterRequestReply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandWrapper request(CommandWrapper wrapper) throws ExecutionException, InterruptedException, IOException {
|
@Override
|
||||||
|
public CommandWrapper request(CommandWrapper wrapper) throws ExecutionException, InterruptedException, IOException {
|
||||||
wrapper.setRequest(UUID.randomUUID().toString());
|
wrapper.setRequest(UUID.randomUUID().toString());
|
||||||
|
|
||||||
AtomicReference<CommandWrapper> responseRef = new AtomicReference<>();
|
AtomicReference<CommandWrapper> responseRef = new AtomicReference<>();
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package de.infinimotion.backend;
|
|
||||||
|
|
||||||
import de.infinimotion.model.backend.*;
|
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
|
||||||
import jakarta.inject.Inject;
|
|
||||||
import jakarta.ws.rs.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
@ApplicationScoped
|
|
||||||
@Path("/kinosaal")
|
|
||||||
public class KinosaalResource {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
BetterRequestReply requester;
|
|
||||||
|
|
||||||
@GET
|
|
||||||
public List<Kinosaal> listKinosaal() throws IOException, ExecutionException, InterruptedException {
|
|
||||||
CommandListKinosaal request = new CommandListKinosaal();
|
|
||||||
CommandWrapper response = requester.request(request.serialize().generateIds().commit());
|
|
||||||
return CommandListKinosaalResponse.deserialize(response).getList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/{id}")
|
|
||||||
public Kinosaal getKinosaal(@PathParam("id") Integer id) throws IOException, ExecutionException, InterruptedException {
|
|
||||||
CommandGetKinosaal request = new CommandGetKinosaal();
|
|
||||||
request.setId(id);
|
|
||||||
|
|
||||||
CommandWrapper response = requester.request(request.serialize().generateIds().commit());
|
|
||||||
return CommandGetKinosaalResponse.deserialize(response).getHall();
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
public Kinosaal createKinosaal(Kinosaal hall) throws IOException, ExecutionException, InterruptedException {
|
|
||||||
CommandCreateKinosaal request = new CommandCreateKinosaal();
|
|
||||||
request.setName(hall.getName());
|
|
||||||
|
|
||||||
CommandWrapper response = requester.request(request.serialize().generateIds().commit());
|
|
||||||
return CommandCreateKinosaalResponse.deserialize(response).getHall();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PUT
|
|
||||||
public Kinosaal updateKinosaal(Kinosaal hall) throws IOException, ExecutionException, InterruptedException {
|
|
||||||
CommandUpdateKinosaal request = new CommandUpdateKinosaal();
|
|
||||||
request.setHall(hall);
|
|
||||||
|
|
||||||
CommandWrapper response = requester.request(request.serialize().generateIds().commit());
|
|
||||||
return CommandUpdateKinosaal.deserialize(response).getHall();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
public Kinosaal deleteKinosaal(Kinosaal hall) throws IOException, ExecutionException, InterruptedException {
|
|
||||||
CommandDeleteKinosaal request = new CommandDeleteKinosaal();
|
|
||||||
request.setHall(hall);
|
|
||||||
|
|
||||||
CommandWrapper response = requester.request(request.serialize().generateIds().commit());
|
|
||||||
return CommandDeleteKinosaalResponse.deserialize(response).getHall();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,9 @@
|
|||||||
quarkus.http.port=7080
|
quarkus.http.port=7080
|
||||||
quarkus.http.root-path=/api/
|
quarkus.http.root-path=/api/
|
||||||
|
|
||||||
|
quarkus.index-dependency.model-backend.group-id=de.infinimotion
|
||||||
|
quarkus.index-dependency.model-backend.artifact-id=model-backend
|
||||||
|
|
||||||
quarkus.swagger-ui.always-include=true
|
quarkus.swagger-ui.always-include=true
|
||||||
quarkus.smallrye-openapi.path=${quarkus.http.root-path}openapi
|
quarkus.smallrye-openapi.path=${quarkus.http.root-path}openapi
|
||||||
quarkus.swagger-ui.path=${quarkus.http.root-path}swagger
|
quarkus.swagger-ui.path=${quarkus.http.root-path}swagger
|
||||||
|
|||||||
Reference in New Issue
Block a user