From be7f42aafe15c7de57d4e9945808c34768c2ff2c Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Fri, 19 Apr 2024 17:37:59 +0200 Subject: [PATCH] fixed POST addview --- .../ScientificPublications/ResearchController.java | 7 ++++--- .../ScientificPublications/ResearchRepository.java | 2 ++ .../src/Apps/ScientificPublications/ResearchComponent.vue | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java index 36b72db..3524d30 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScientificPublications/ResearchController.java @@ -229,10 +229,11 @@ public class ResearchController { /////// //views part - @PostMapping("/addview/{url}") + @PostMapping("/addview/cdn/{url}") public ResponseEntity addView(@PathVariable String url){ - Research research = researchesServ.getResearchByUrl(url); - if (research ==null) return new ResponseEntity<>(HttpStatus.NOT_FOUND); + System.out.println(url); + Research research = researchesServ.getResearchByUrl("cdn/" + url); + if (research ==null) return new ResponseEntity<>(HttpStatus.BAD_REQUEST); return new ResponseEntity<>(ResearchDTO.construct(researchesServ.addView(research)), HttpStatus.OK); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearchRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearchRepository.java index ace303d..f2d1cf2 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearchRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScientificPublications/ResearchRepository.java @@ -1,5 +1,6 @@ package ovh.herisson.Clyde.Repositories.ScientificPublications; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import ovh.herisson.Clyde.Tables.ScientificPublications.Research; import ovh.herisson.Clyde.Tables.ScientificPublications.Researcher; @@ -12,6 +13,7 @@ public interface ResearchRepository extends CrudRepository { Iterable findByAuthor(Researcher author); + @Query("select r from Research r where r.pdfLocation = ?1") Research findByPdfLocation(String url); } diff --git a/frontend/src/Apps/ScientificPublications/ResearchComponent.vue b/frontend/src/Apps/ScientificPublications/ResearchComponent.vue index 33dabec..a725ec3 100644 --- a/frontend/src/Apps/ScientificPublications/ResearchComponent.vue +++ b/frontend/src/Apps/ScientificPublications/ResearchComponent.vue @@ -62,6 +62,7 @@ function downloadBibTex(){ async function articleClicked(){ await addView(props.article.pdfLocation) emit('modal-close') + emit('modified') } /**