Bladeren bron

ProcesController.java created

Drowsito 4 dagen geleden
bovenliggende
commit
ad78215288
2 gewijzigde bestanden met toevoegingen van 42 en 0 verwijderingen
  1. 5 0
      src/main/java/es/uv/saic/dto/ProcesDTO.java
  2. 37 0
      src/main/java/es/uv/saic/web/ProcesController.java

+ 5 - 0
src/main/java/es/uv/saic/dto/ProcesDTO.java

@@ -0,0 +1,5 @@
+package es.uv.saic.dto;
+
+public interface ProcesDTO {
+    
+}

+ 37 - 0
src/main/java/es/uv/saic/web/ProcesController.java

@@ -0,0 +1,37 @@
+package es.uv.saic.web;
+
+import java.math.BigInteger;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+import es.uv.saic.domain.Proces;
+import es.uv.saic.service.ProcesService;
+
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+
+
+@RestController
+public class ProcesController {
+    @Autowired
+    private ProcesService procesService;
+
+    @PostMapping("/proces/{id}")
+    public ResponseEntity<?> findById(@PathVariable Integer id) {
+        try {
+            Proces proces = procesService.findByID(id);
+
+            if (proces != null){
+                return ResponseEntity.ok(proces);
+            }
+
+            return ResponseEntity.badRequest().body("El proces con id " + id + " esta vacio");
+        } catch (Exception e) {
+             e.printStackTrace();
+            return ResponseEntity.badRequest().body("Error al obtener el proces por el id:" +  e.getMessage());
+        }
+    }
+    
+}