Browse Source

CRUD operations

dagarcos 2 years ago
parent
commit
0355b24653
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/main/java/es/uv/garcosda/controllers/NewsController.java

+ 7 - 2
src/main/java/es/uv/garcosda/controllers/NewsController.java

@@ -1,5 +1,8 @@
 package es.uv.garcosda.controllers;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -30,6 +33,7 @@ public class NewsController {
 	
 	@PostMapping()
 	public Mono<Document> insert(@RequestBody Document n){
+		n.setDateAdd(new SimpleDateFormat("dd-MM-yyyy").format(new Date()));
 		return this.ns.insert(n);	
 	}
 	
@@ -39,8 +43,9 @@ public class NewsController {
 	}
 	
 	@DeleteMapping("{id}")
-	public Mono<Void> delete(@PathVariable("id") Integer id){
-		return this.ns.deleteById(id);
+	public Mono<Integer> delete(@PathVariable("id") Integer id){
+		return this.ns.deleteById(id).then(Mono.just(id));
+		
 	}
 	
 }