From 296f34328f87af2c1c2277a2bd7aa183c1d7b0f9 Mon Sep 17 00:00:00 2001 From: Roxane Date: Mon, 26 Feb 2024 17:19:34 +0100 Subject: [PATCH] cleanning production of the day --- WebService/pom.xml | 46 +------- WebService/pom_LOCAL_26800.xml | 50 -------- .../controller/CollectController.java | 16 +++ .../controller/CollectionControlleur.java | 109 ------------------ .../SAE/ApiREST/WebService/model/Article.java | 1 + 5 files changed, 18 insertions(+), 204 deletions(-) delete mode 100644 WebService/pom_LOCAL_26800.xml create mode 100644 WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectController.java delete mode 100644 WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectionControlleur.java diff --git a/WebService/pom.xml b/WebService/pom.xml index 7344a54..6a8f4b5 100644 --- a/WebService/pom.xml +++ b/WebService/pom.xml @@ -1,46 +1,6 @@ -import org.springframework.web.bind.annotation.*; - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.2.2 - - - com.example - WebService - 0.0.1-SNAPSHOT - tp2 - Demo project for Spring Boot - - 17 - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-web - - - jakarta.persistence - jakarta.persistence-api - - -======= - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot @@ -67,7 +27,6 @@ import org.springframework.web.bind.annotation.*; spring-boot-starter-test test ->>>>>>> origin/Maxime org.springframework.boot @@ -79,8 +38,6 @@ import org.springframework.web.bind.annotation.*; -<<<<<<< HEAD -======= @@ -90,5 +47,4 @@ import org.springframework.web.bind.annotation.*; ->>>>>>> origin/Maxime \ No newline at end of file diff --git a/WebService/pom_LOCAL_26800.xml b/WebService/pom_LOCAL_26800.xml deleted file mode 100644 index 67a2f9f..0000000 --- a/WebService/pom_LOCAL_26800.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.2.2 - - - com.example - WebService - 0.0.1-SNAPSHOT - tp2 - Demo project for Spring Boot - - 17 - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-web - - - jakarta.persistence - jakarta.persistence-api - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - \ No newline at end of file diff --git a/WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectController.java b/WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectController.java new file mode 100644 index 0000000..99b3545 --- /dev/null +++ b/WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectController.java @@ -0,0 +1,16 @@ +package SAE.ApiREST.WebService.controller; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller + @RequestMapping("/CollectWebService") + public class CollectController { + + } + diff --git a/WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectionControlleur.java b/WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectionControlleur.java deleted file mode 100644 index d0a6f3d..0000000 --- a/WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectionControlleur.java +++ /dev/null @@ -1,109 +0,0 @@ -package SAE.ApiREST.WebService.controller; - -@org.springframework.stereotype.Controller - -@Controller -@RequestMapping("/CollectionWebService") -public class CollectionController { - private ArrayList collections = new ArrayList<>(); - - public Controller() { - - } - - @GetMapping(value = "/getAllCollection", produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody List getAllCollection() { - return collections; - } - - @GetMapping(value = "/getCollectionById/{isbn}", produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody Book getCollectionById(@PathVariable(value = "isbn") int isbn) { - for(Book book : books) { - if(book.isbn == isbn) { - return book; - } - } - throw new BookException("Undefined id"); - } - - @PostMapping("/logBooks") - public @ResponseBody void logBooks(@RequestParam("title") String title, @RequestParam("author") String author) { - books.add(new Book(title, author)); - for(Book book : books) { - System.out.println(book); - } - } - // region Collection - - // region GET - @GetMapping(value = "/getCollectionById", produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody Collection getCollectionById(long isbn){ - for(Collection collection : this.collections){ - if(collection.getId === isbn) { - return collection; - } - } - return null; - } - @GetMapping(value = "/getAllCollectionsByName", produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody List getAllCollectionsByName(String name){ - private ArrayList repCollections = new ArrayList(); - for(Collection collection : this.collections){ - if(collection.getName === name) { - repCollections.add(collection); - } - } - return repCollections; - } - // endregion - - // region DELETE - @DeleteMaping(value = "/deleteColletionById") - public @ResponseBody void deleteColletionById(long isbn){ - Collection collection = getCollectionById(isbn); - this.collections.remove(collection); - } - - public @ResponseBody void deleteColletionByName(String name){ - ArrayList collectionsByName = getAllCollectionsByName(name); - this.collections.remove(collectionsByName[0]); - } - public @ResponseBody void deleteAllColletionByName(String name){ - ArrayList collectionsByName = getAllCollectionsByName(name); - this.collections.removeAll(collectionsByName); - } - // endregion - - // region PUT - public @ResponseBody void addCollection(Collection collection){ - this.collections.add(collection); - } - public @ResponseBody void addCollections(List collections){ - this.collections.addAll(collections); - } - // endregion - - // region POST - public @ResponseBody void modifyCollectionName(Collection collection, String name){ - collection.setName(name); - } - public @ResponseBody void modifyCollectionNameById(long isbn, String name){ - Collection collection = getCollectionById(isbn); - modifyCollectionName(collection,name); - } - // endregion - // endregion - - // region Article - @GetMapping(value = "/getAllArticles", produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody List
getAllArticles(Collection collection){ - return collection.getAllArticles; - } - public @ResponseBody void addArticle(Collection collection, Article article){ - collection.addArticle - } - public @ResponseBody void deleteArticle(Collection collection, Article article){ - collection.deleteArticle(article); - } - // endregion -} diff --git a/WebService/src/main/java/SAE/ApiREST/WebService/model/Article.java b/WebService/src/main/java/SAE/ApiREST/WebService/model/Article.java index 49380f2..67997db 100644 --- a/WebService/src/main/java/SAE/ApiREST/WebService/model/Article.java +++ b/WebService/src/main/java/SAE/ApiREST/WebService/model/Article.java @@ -12,6 +12,7 @@ import jakarta.persistence.Id; public class Article { @Id @GeneratedValue(strategy = GenerationType.AUTO) + String title; String URL; LocalDate dateAdded;