generate crud for models

This commit is contained in:
2025-10-26 00:04:00 +02:00
parent f29e669e25
commit 71cf9b1283
4 changed files with 8 additions and 66 deletions

View File

@@ -35,7 +35,7 @@
<dependency>
<groupId>de.infinimotion</groupId>
<artifactId>model-backend</artifactId>
<version>0.0.56</version>
<version>0.0.64</version>
</dependency>
<!-- Quarkus -->

View File

@@ -2,6 +2,7 @@ package de.infinimotion.backend;
import de.infinimotion.model.backend.CommandException;
import de.infinimotion.model.backend.CommandWrapper;
import de.infinimotion.model.backend.RequestReply;
import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.reactive.messaging.Channel;
import org.eclipse.microprofile.reactive.messaging.Emitter;
@@ -15,7 +16,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference;
@ApplicationScoped
public class BetterRequestReply {
public class BetterRequestReply implements RequestReply {
@Channel("command")
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());
AtomicReference<CommandWrapper> responseRef = new AtomicReference<>();

View File

@@ -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();
}
}

View File

@@ -2,6 +2,9 @@
quarkus.http.port=7080
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.smallrye-openapi.path=${quarkus.http.root-path}openapi
quarkus.swagger-ui.path=${quarkus.http.root-path}swagger