parent
0fa91cbf59
commit
c4f977c45a
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/WebService/src/main/java" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,16 +1,98 @@
|
|||||||
package SAE.ApiREST.WebService.controller;
|
package SAE.ApiREST.WebService.controller;
|
||||||
|
|
||||||
|
import SAE.ApiREST.WebService.model.Article;
|
||||||
|
import SAE.ApiREST.WebService.model.Collect;
|
||||||
|
import SAE.ApiREST.WebService.service.ICollectionService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
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.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/CollectWebService")
|
@RequestMapping("/CollectWebService")
|
||||||
public class CollectController {
|
public class CollectController {
|
||||||
|
@Autowired
|
||||||
|
ICollectionService collectionService;
|
||||||
|
|
||||||
|
public CollectController() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// region Collection
|
||||||
|
|
||||||
|
// region GET
|
||||||
|
@GetMapping(value = "/getAllCollection", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody List<Collect> getAllCollection(){
|
||||||
|
return collectionService.getAllCollections();
|
||||||
|
}
|
||||||
|
@GetMapping(value = "/getCollectionById/{isbn}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody Collect getCollectionById(@PathVariable(value = "isbn") long isbn){
|
||||||
|
return collectionService.getCollectionById(isbn);
|
||||||
|
}
|
||||||
|
@GetMapping(value = "/getAllCollectionsByName/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody List<Collect> getAllCollectionsByName(@PathVariable(value = "name") String name){
|
||||||
|
return collectionService.getAllCollectionsByName(name);
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region DELETE
|
||||||
|
@DeleteMapping(value = "/deleteColletionById/{isbn}")
|
||||||
|
public @ResponseBody void deleteColletionById(@RequestParam("isbn") long isbn){
|
||||||
|
collectionService.deleteColletionById(isbn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping(value = "/deleteColletionByName/{name}")
|
||||||
|
public @ResponseBody void deleteColletionByName(@RequestParam("name") String name){
|
||||||
|
collectionService.deleteColletionByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping(value = "/deleteAllColletionByName/{name}")
|
||||||
|
public @ResponseBody void deleteAllColletionByName(@RequestParam("name") String name){
|
||||||
|
collectionService.deleteAllColletionByName(name);
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region PUT
|
||||||
|
@PutMapping(value = "/addCollection")
|
||||||
|
public @ResponseBody void addCollection(@RequestParam("collection") Collect collection){
|
||||||
|
collectionService.addCollection(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping(value = "/addCollections")
|
||||||
|
public @ResponseBody void addCollections(@RequestParam("collections") List<Collect> collections){
|
||||||
|
collectionService.addCollections(collections);
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region POST
|
||||||
|
@PostMapping(value="/modifyCollectionName", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody void modifyCollectionName(@RequestParam("collection") Collect collection, @RequestParam("name") String name){
|
||||||
|
collectionService.modifyCollectionName(collection,name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value="/modifyCollectionNameById", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody void modifyCollectionNameById(@RequestParam("isbn") long isbn, @RequestParam("name") String name){
|
||||||
|
collectionService.modifyCollectionNameById(isbn,name);
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region Article
|
||||||
|
@GetMapping(value = "/getAllArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody List<Article> getAllArticles(@RequestParam("collection") Collect collection){
|
||||||
|
return collectionService.getAllArticles(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping(value = "/addArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody void addArticle(@RequestParam("collection") Collect collection, @RequestParam("article") Article article){
|
||||||
|
collectionService.addArticle(collection,article);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping(value = "/deleteArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
public @ResponseBody void deleteArticle(@RequestParam("collection") Collect collection, @RequestParam("article") Article article){
|
||||||
|
collectionService.deleteArticle(collection,article);
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
|
}
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
@org.springframework.stereotype.Controller
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/CollectionWebService")
|
|
||||||
public class CollectionController {
|
|
||||||
private ArrayList<Collection> collections = new ArrayList<>();
|
|
||||||
|
|
||||||
public Controller() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// region Collection
|
|
||||||
|
|
||||||
// region GET
|
|
||||||
@GetMapping(value = "/getCollectionById/{isbn}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody Collection getCollectionById(@PathVariable(value = "isbn") long isbn){
|
|
||||||
for(Collection collection : this.collections){
|
|
||||||
if(collection.getId === isbn) {
|
|
||||||
return collection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@GetMapping(value = "/getAllCollectionsByName/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody List<Collection> getAllCollectionsByName(@PathVariable(value = "name") String name){
|
|
||||||
private ArrayList<Collection> repCollections = new ArrayList<Collection>();
|
|
||||||
for(Collection collection : this.collections){
|
|
||||||
if(collection.getName === name) {
|
|
||||||
repCollections.add(collection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return repCollections;
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region DELETE
|
|
||||||
@DeleteMapping(value = "/deleteColletionById/{isbn}")
|
|
||||||
public @ResponseBody void deleteColletionById(@RequestParam("isbn") long isbn){
|
|
||||||
Collection collection = getCollectionById(isbn);
|
|
||||||
this.collections.remove(collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping(value = "/deleteColletionByName/{name}")
|
|
||||||
public @ResponseBody void deleteColletionByName(@RequestParam("name") String name){
|
|
||||||
ArrayList<Collection> collectionsByName = getAllCollectionsByName(name);
|
|
||||||
this.collections.remove(collectionsByName[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping(value = "/deleteAllColletionByName/{name}")
|
|
||||||
public @ResponseBody void deleteAllColletionByName(@RequestParam("name") String name){
|
|
||||||
ArrayList<Collection> collectionsByName = getAllCollectionsByName(name);
|
|
||||||
this.collections.removeAll(collectionsByName);
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region PUT
|
|
||||||
@PutMapping(value = "/addCollection")
|
|
||||||
public @ResponseBody void addCollection(@RequestParam("collection") Collection collection){
|
|
||||||
this.collections.add(collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping(value = "/addCollections")
|
|
||||||
public @ResponseBody void addCollections(@RequestParam("collections") List<Collection> collections){
|
|
||||||
this.collections.addAll(collections);
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region POST
|
|
||||||
@PostMapping("/modifyCollectionName", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody void modifyCollectionName(@RequestParam("collection") Collection collection, @RequestParam("name") String name){
|
|
||||||
collection.setName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/modifyCollectionNameById", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody void modifyCollectionNameById(@RequestParam("isbn") long isbn, @RequestParam("name") String name){
|
|
||||||
Collection collection = getCollectionById(isbn);
|
|
||||||
modifyCollectionName(collection,name);
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Article
|
|
||||||
@GetMapping(value = "/getAllArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody List<Article> getAllArticles(@RequestParam("collection") Collection collection){
|
|
||||||
return collection.getAllArticles;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping(value = "/addArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody void addArticle(@RequestParam("collection") Collection collection, @RequestParam("article") Article article){
|
|
||||||
collection.addArticle
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping(value = "/deleteArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public @ResponseBody void deleteArticle(@RequestParam("collection") Collection collection, @RequestParam("article") Article article){
|
|
||||||
collection.deleteArticle(article);
|
|
||||||
}
|
|
||||||
// endregion
|
|
||||||
}
|
|
Loading…
Reference in new issue