|
|
@@ -8,12 +8,13 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import es.uv.saic.dto.ArchiveOrganDTO;
|
|
|
import es.uv.saic.dto.CategoriaDTO;
|
|
|
import es.uv.saic.dto.DocumentTmpDTO;
|
|
|
import es.uv.saic.domain.Document;
|
|
|
import es.uv.saic.service.DocumentService;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
@@ -28,7 +29,7 @@ public class DocumentController {
|
|
|
try {
|
|
|
Document auxDocument = ds.save(doc);
|
|
|
return (auxDocument != null) ? ResponseEntity.ok(auxDocument) :
|
|
|
- ResponseEntity.badRequest().body("El documento no se a podido guardad correctamente.") ;
|
|
|
+ ResponseEntity.badRequest().body("El documento no se ha podido guardar correctamente.") ;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseEntity.badRequest().body("Hubo un error al procesar el documento: " + e.getMessage());
|
|
|
@@ -43,7 +44,7 @@ public class DocumentController {
|
|
|
try {
|
|
|
Document document = ds.findByCategoriaOrgan(categoria.getCategoria(), categoria.getLugar(), categoria.getTlugar());
|
|
|
return (document != null) ? ResponseEntity.ok(document) :
|
|
|
- ResponseEntity.badRequest().body("El documento no se a podido encontrar.") ;
|
|
|
+ ResponseEntity.badRequest().body("El documento no se ha podido encontrar.") ;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseEntity.badRequest().body("Hubo un error al procesar el documento: " + e.getMessage());
|
|
|
@@ -54,11 +55,11 @@ public class DocumentController {
|
|
|
* endpoint para findByID
|
|
|
*/
|
|
|
@GetMapping("/document/{idDocument}")
|
|
|
- public ResponseEntity<?> findByID(@RequestParam Integer idDocument) {
|
|
|
+ public ResponseEntity<?> findByID(@PathVariable Integer idDocument) {
|
|
|
try {
|
|
|
Document document = ds.findById(idDocument);
|
|
|
return (document != null) ? ResponseEntity.ok(document) :
|
|
|
- ResponseEntity.badRequest().body("El documento no se a podido encontrar.") ;
|
|
|
+ ResponseEntity.badRequest().body("El documento no se ha podido encontrar.") ;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseEntity.badRequest().body("No se encontro el documento: " + e.getMessage());
|
|
|
@@ -88,11 +89,18 @@ public class DocumentController {
|
|
|
try {
|
|
|
Document auxDocument = ds.archive(doc);
|
|
|
return (auxDocument != null) ? ResponseEntity.ok(auxDocument) :
|
|
|
- ResponseEntity.badRequest().body("El documento no se a podido archivar correctamente.") ;
|
|
|
+ ResponseEntity.badRequest().body("El documento no se ha podido archivar correctamente.") ;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseEntity.badRequest().body("Hubo un error al procesar el documento: " + e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/archiveByOrgan")
|
|
|
+ public ResponseEntity<?> archiveByOrgan(@RequestBody ArchiveOrganDTO organ) {
|
|
|
+ ds.archiveByOrgan(organ.getLugar(), organ.getTlugar());
|
|
|
+ return ResponseEntity.ok().build();
|
|
|
+ }
|
|
|
+
|
|
|
}
|