kinosaal crud
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-persistence</artifactId>
|
<artifactId>model-persistence</artifactId>
|
||||||
<version>0.0.54</version>
|
<version>0.0.55</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Quarkus -->
|
<!-- Quarkus -->
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ import java.util.List;
|
|||||||
|
|
||||||
@Unremovable
|
@Unremovable
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class KinosaalProcessor implements CommandListKinosaalProcessor, CommandCreateKinosaalProcessor {
|
public class KinosaalProcessor implements CommandListKinosaalProcessor, CommandCreateKinosaalProcessor, CommandUpdateKinosaalProcessor, CommandDeleteKinosaalProcessor {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
EntityManager em;
|
EntityManager em;
|
||||||
|
|
||||||
public Command processCommandListKinosaal(CommandListKinosaal request) {
|
public Command processCommandListKinosaal(CommandListKinosaal request) {
|
||||||
List<Kinosaal> results = em.createQuery("SELECT k FROM Kinosaal k", Kinosaal.class).getResultList();
|
List<Kinosaal> results = em.createQuery("SELECT k FROM Kinosaal k", Kinosaal.class).getResultList();
|
||||||
|
|
||||||
CommandListKinosaalResponse response = new CommandListKinosaalResponse();
|
CommandListKinosaalResponse response = new CommandListKinosaalResponse();
|
||||||
response.setList(results);
|
response.setList(results);
|
||||||
return response;
|
return response;
|
||||||
@@ -26,9 +27,28 @@ public class KinosaalProcessor implements CommandListKinosaalProcessor, CommandC
|
|||||||
Kinosaal hall = new Kinosaal();
|
Kinosaal hall = new Kinosaal();
|
||||||
hall.setName(request.getName());
|
hall.setName(request.getName());
|
||||||
em.persist(hall);
|
em.persist(hall);
|
||||||
|
|
||||||
CommandCreateKinosaalResponse response = new CommandCreateKinosaalResponse();
|
CommandCreateKinosaalResponse response = new CommandCreateKinosaalResponse();
|
||||||
response.setHall(hall);
|
response.setHall(hall);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Command processCommandDeleteKinosaal(CommandDeleteKinosaal request) {
|
||||||
|
Kinosaal hall = em.find(Kinosaal.class, request.getHall().getId());
|
||||||
|
em.remove(hall);
|
||||||
|
|
||||||
|
CommandDeleteKinosaalResponse response = new CommandDeleteKinosaalResponse();
|
||||||
|
response.setHall(hall);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Command processCommandUpdateKinosaal(CommandUpdateKinosaal request) {
|
||||||
|
Kinosaal hall = em.merge(request.getHall());
|
||||||
|
|
||||||
|
CommandUpdateKinosaal response = new CommandUpdateKinosaal();
|
||||||
|
response.setHall(hall);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user