|
|
|
@ -5,6 +5,7 @@ import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import SAE.ApiREST.WebService.Response;
|
|
|
|
|
import SAE.ApiREST.WebService.exception.ArticleException;
|
|
|
|
|
import SAE.ApiREST.WebService.model.Article;
|
|
|
|
|
import SAE.ApiREST.WebService.service.IArticleService;
|
|
|
|
@ -19,15 +20,92 @@ public class ArticleControler {
|
|
|
|
|
IArticleService articleService;
|
|
|
|
|
|
|
|
|
|
// region POST
|
|
|
|
|
|
|
|
|
|
@PostMapping(
|
|
|
|
|
value = "/addArticle",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response addArticle(
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.addArticle(article);
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
// region PUT
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
|
value = "/updateTitle/{title}",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Article updateTitle(
|
|
|
|
|
@PathVariable("title") String title,
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.updateTitle(article, title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
|
value = "/updateUrl/{url}",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Article updateUrl(
|
|
|
|
|
@PathVariable("url") String url,
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.updateUrl(article, url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
|
value = "/updateDatePublished/{datePublished}",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Article updateDatePublished(
|
|
|
|
|
@PathVariable("datePublished") String datePublished,
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.updateDatePublished(article, datePublished);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
|
value = "/updateDateAdded/{dateAdded}",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Article updateDateAdded(
|
|
|
|
|
@PathVariable("dateAdded") String dateAdded,
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.updateDateAdded(article, dateAdded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
|
value = "/changeVisibility",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Article changeVisibility(
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.changeVisibility(article);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
|
value = "/updateType/{type}",
|
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Article updateType(
|
|
|
|
|
@PathVariable("type") Integer type,
|
|
|
|
|
@RequestBody Article article
|
|
|
|
|
) {
|
|
|
|
|
return articleService.updateType(article, type);
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
// region GET
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getAllArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
public @ResponseBody List<Article> getAllArticles() {
|
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getAllArticles();
|
|
|
|
@ -160,6 +238,94 @@ public class ArticleControler {
|
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
// region DELETE
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticleFromId/{id}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticleFromId(
|
|
|
|
|
@PathVariable("id") Integer id
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticleFromId(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticleFromTitle/{title}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticleFromTitle(
|
|
|
|
|
@PathVariable("title") String title
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticleFromTitle(title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticleFromUrl/{url}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticleFromUrl(
|
|
|
|
|
@PathVariable("url") String url
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticleFromUrl(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticleAddedBefore/{date}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticleAddedBefore(
|
|
|
|
|
@PathVariable("date") String date
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticleAddedBefore(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticleAddedAfter/{date}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticleAddedAfter(
|
|
|
|
|
@PathVariable("date") String date
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticleAddedAfter(date);
|
|
|
|
|
}@DeleteMapping(
|
|
|
|
|
value = "/deleteArticleAddedBetween/{beginning}/{end}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticleAddedBetween(
|
|
|
|
|
@PathVariable("beginning") String beginning,
|
|
|
|
|
@PathVariable("end") String end
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticleAddedBetween(beginning, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticlePublishedBefore/{date}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticlePublishedBefore(
|
|
|
|
|
@PathVariable("date") String date
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticlePublishedBefore(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticlePublishedAfter/{date}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticlePublishedAfter(
|
|
|
|
|
@PathVariable("date") String date
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticlePublishedAfter(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
value = "/deleteArticlePublishedBetween/{beginning}/{end}",
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
)
|
|
|
|
|
public @ResponseBody Response deleteArticlePublishedBetween(
|
|
|
|
|
@PathVariable("beginning") String beginning,
|
|
|
|
|
@PathVariable("end") String end
|
|
|
|
|
) {
|
|
|
|
|
return articleService.deleteArticlePublishedBetween(beginning, end);
|
|
|
|
|
}
|
|
|
|
|
// endregion
|
|
|
|
|
}
|
|
|
|
|