generate crud for models
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -35,7 +35,7 @@
|
||||
<dependency>
|
||||
<groupId>de.infinimotion</groupId>
|
||||
<artifactId>model-persistence</artifactId>
|
||||
<version>0.0.56</version>
|
||||
<version>0.0.64</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Quarkus -->
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
package de.infinimotion.persistence.processor;
|
||||
|
||||
import de.infinimotion.model.persistence.*;
|
||||
import io.quarkus.arc.Unremovable;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.persistence.EntityManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Unremovable
|
||||
@ApplicationScoped
|
||||
public class KinosaalProcessor implements CommandListKinosaalProcessor, CommandGetKinosaalProcessor, CommandCreateKinosaalProcessor, CommandUpdateKinosaalProcessor, CommandDeleteKinosaalProcessor {
|
||||
|
||||
@Inject
|
||||
EntityManager em;
|
||||
|
||||
@Override
|
||||
public Command processCommandListKinosaal(CommandListKinosaal request) {
|
||||
List<Kinosaal> results = em.createQuery("SELECT k FROM Kinosaal k", Kinosaal.class).getResultList();
|
||||
|
||||
CommandListKinosaalResponse response = new CommandListKinosaalResponse();
|
||||
response.setList(results);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command processCommandGetKinosaal(CommandGetKinosaal request) throws Exception {
|
||||
Kinosaal hall = em.find(Kinosaal.class, request.getId());
|
||||
|
||||
CommandGetKinosaalResponse response = new CommandGetKinosaalResponse();
|
||||
response.setHall(hall);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command processCommandCreateKinosaal(CommandCreateKinosaal request) {
|
||||
Kinosaal hall = new Kinosaal();
|
||||
hall.setName(request.getName());
|
||||
em.persist(hall);
|
||||
|
||||
CommandCreateKinosaalResponse response = new CommandCreateKinosaalResponse();
|
||||
response.setHall(hall);
|
||||
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