# Conflicts: # WebService/src/main/java/SAE/ApiREST/WebService/controller/CollectionControlleur.java # WebService/src/main/java/SAE/ApiREST/WebService/service/StubCollectionService.javaMaxime
commit
0fa91cbf59
@ -0,0 +1,30 @@
|
||||
package SAE.ApiREST.WebService;
|
||||
|
||||
public class Response {
|
||||
|
||||
Integer id;
|
||||
String statusMessage;
|
||||
|
||||
public Response() {}
|
||||
|
||||
public Response(Integer id, String statusMessage) {
|
||||
this.id = id;
|
||||
this.statusMessage = statusMessage;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getStatusMessage() {
|
||||
return this.statusMessage;
|
||||
}
|
||||
|
||||
public void setStatusMessage(String statusMessage) {
|
||||
this.statusMessage = statusMessage;
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package SAE.ApiREST.WebService.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import SAE.ApiREST.WebService.exception.ArticleException;
|
||||
import SAE.ApiREST.WebService.model.Article;
|
||||
import SAE.ApiREST.WebService.service.IArticleService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/ArticleWebService")
|
||||
public class ArticleControler {
|
||||
@Autowired
|
||||
IArticleService articleService;
|
||||
|
||||
// region POST
|
||||
|
||||
// endregion
|
||||
|
||||
// region PUT
|
||||
|
||||
// endregion
|
||||
|
||||
// region GET
|
||||
|
||||
@GetMapping(value = "/getAllArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getAllArticles() {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getAllArticles();
|
||||
|
||||
if(results.isEmpty()) {
|
||||
throw new ArticleException("No articles available");
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticleById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody Article getArticlesById(@PathVariable(value = "id") Integer id) {
|
||||
Article results = articleService.getArticlesById(id);
|
||||
|
||||
if(results == null) {
|
||||
throw new ArticleException("Undefined id");
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesByTitle/{title}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesByTitle(@PathVariable(value = "title") String title) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByTitle(title);
|
||||
|
||||
if(results.isEmpty()) {
|
||||
throw new ArticleException("Undefined title");
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesByType/{type}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesByType(@PathVariable(value = "type") Integer type) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByType(type);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No content of type %d", type));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getVisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getVisibleArticles() {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getVisibleArticles();
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException("No visible article");
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getInvisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getInvisibleArticles() {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getInvisibleArticles();
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException("No invisible article");
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesAddedBefore/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesAddedBefore(@PathVariable(value = "dateAdded") String dateAdded) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedBefore(dateAdded);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No article added before %t", dateAdded));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesAddedAfter/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesAddedAfter(@PathVariable(value = "dateAdded") String dateAdded) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedAfter(dateAdded);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No article added after %t", dateAdded));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesAddedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesAddedAfter(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedBetween(beginning, end);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No article added between %t and %t", beginning, end));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesPublishedBefore/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesPublishedBefore(@PathVariable(value = "datePublished") String datePublished) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedBefore(datePublished);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No article published before %t", datePublished));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesPublishedAfter/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesPublishedAfter(@PathVariable(value = "datePublished") String datePublished) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedAfter(datePublished);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No article published after %t", datePublished));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getArticlesPublishedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public @ResponseBody List<Article> getArticlesPublishedAfter(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) {
|
||||
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedBetween(beginning, end);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
throw new ArticleException(String.format("No article published between %t and %t", beginning, end));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region DELETE
|
||||
|
||||
// endregion
|
||||
}
|
@ -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 {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package SAE.ApiREST.WebService.controller;
|
||||
|
||||
import SAE.ApiREST.WebService.model.Teacher;
|
||||
import SAE.ApiREST.WebService.service.ITeacherService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.print.attribute.standard.Media;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/ProfWebService")
|
||||
public class TeacherController {
|
||||
@Autowired
|
||||
private ITeacherService iTeacherServ;
|
||||
|
||||
|
||||
public TeacherController(ITeacherService iserv) {
|
||||
this.iTeacherServ = iserv;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/all", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public List<Teacher> getAllTeacher(){
|
||||
return iTeacherServ.getAllTeacher();
|
||||
}
|
||||
|
||||
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Teacher createTeacher( @RequestBody Teacher teach){
|
||||
return teach;
|
||||
}
|
||||
|
||||
//@GetMapping(value = "/{id}")
|
||||
//public
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package SAE.ApiREST.WebService.exception;
|
||||
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@ControllerAdvice
|
||||
public class ArticleAdvice {
|
||||
@ResponseBody
|
||||
@ExceptionHandler(ArticleException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
String articleHandler(ArticleException ex) {
|
||||
return ex.getMessage();
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package SAE.ApiREST.WebService.exception;
|
||||
|
||||
public class ArticleException extends RuntimeException {
|
||||
public ArticleException(String exception) {
|
||||
super(exception);
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package SAE.ApiREST.WebService.model;
|
||||
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Article {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
String id;
|
||||
>>>>>>> origin/feature/response
|
||||
String title;
|
||||
String URL;
|
||||
LocalDate dateAdded;
|
||||
LocalDate datePublished;
|
||||
Boolean isVisible;
|
||||
Integer type;
|
||||
// ArrayList<Keyword> keywords = new ArrayList<>();
|
||||
|
||||
public Article() {}
|
||||
|
||||
public Article(String title, String URL, LocalDate dateAdded, LocalDate datePublished, Boolean visibility, Integer type) {
|
||||
this.id = "1";
|
||||
this.title = title;
|
||||
this.URL = URL;
|
||||
this.dateAdded = dateAdded;
|
||||
this.datePublished = datePublished;
|
||||
this.isVisible = visibility;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return this.URL;
|
||||
}
|
||||
|
||||
public void setURL(String URL) {
|
||||
this.URL = URL;
|
||||
}
|
||||
|
||||
public LocalDate getDateAdded() {
|
||||
return this.dateAdded;
|
||||
}
|
||||
|
||||
public void setDateAdded(LocalDate dateAdded) {
|
||||
this.dateAdded = dateAdded;
|
||||
}
|
||||
|
||||
public LocalDate getDatePublished() {
|
||||
return this.datePublished;
|
||||
}
|
||||
|
||||
public void setDatePublished(LocalDate datePublished) {
|
||||
this.datePublished = datePublished;
|
||||
}
|
||||
|
||||
public Boolean isVisible() {
|
||||
return this.isVisible;
|
||||
}
|
||||
|
||||
public void setVisibility(Boolean isVisible) {
|
||||
this.isVisible = isVisible;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
/*
|
||||
public List<Keyword> getKeywords() {
|
||||
return this.keywords;
|
||||
}
|
||||
|
||||
public void setKeywords(List<Keyword> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,22 +1,30 @@
|
||||
package SAE.ApiREST.WebService.Data;
|
||||
package SAE.ApiREST.WebService.model;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class Collection{
|
||||
public class Collect {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
private final long isbn
|
||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
||||
private final long isbn = 0;
|
||||
@Column(name = "articles")
|
||||
private ArrayList<Article> articles
|
||||
private ArrayList<Article> articles;
|
||||
@Column(name = "name")
|
||||
private String name
|
||||
private String name;
|
||||
@Column(name = "teacher")
|
||||
private Teacher teacher
|
||||
private Teacher teacher;
|
||||
|
||||
public Collection(String name, Teacher teacher){
|
||||
public Collect(String name, Teacher teacher){
|
||||
this.name = name;
|
||||
this.teacher = teacher;
|
||||
this.articles = new ArrayList<Article>();
|
||||
}
|
||||
|
||||
public Collect() {
|
||||
}
|
||||
|
||||
// region Article
|
||||
public long getId(){
|
||||
return isbn;
|
@ -0,0 +1,60 @@
|
||||
package SAE.ApiREST.WebService.model;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
|
||||
public class Teacher {
|
||||
@Id
|
||||
private Integer id;
|
||||
private LocalDate date;
|
||||
private String mail;
|
||||
private String username;
|
||||
|
||||
public Teacher() {
|
||||
|
||||
}
|
||||
|
||||
public Teacher(Integer id, String date, String mail, String username) {
|
||||
this.id = id;
|
||||
this.date = LocalDate.parse(date, DateTimeFormatter.ISO_DATE);
|
||||
this.mail = mail;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getMail() {
|
||||
return mail;
|
||||
}
|
||||
|
||||
public void setMail(String mail) {
|
||||
this.mail = mail;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package SAE.ApiREST.WebService.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import SAE.ApiREST.WebService.model.Article;
|
||||
|
||||
public interface IArticleService {
|
||||
|
||||
// region GET
|
||||
public List<Article> getAllArticles();
|
||||
Article getArticlesById(Integer id);
|
||||
public List<Article> getArticlesByTitle(String title);
|
||||
public List<Article> getArticlesByType(Integer type);
|
||||
public List<Article> getVisibleArticles();
|
||||
public List<Article> getInvisibleArticles();
|
||||
public List<Article> getArticlesAddedBefore(String dateAdded);
|
||||
public List<Article> getArticlesAddedAfter(String dateAdded);
|
||||
public List<Article> getArticlesAddedBetween(String beginning, String end);
|
||||
public List<Article> getArticlesPublishedBefore(String datePublished);
|
||||
public List<Article> getArticlesPublishedAfter(String datePublished);
|
||||
public List<Article> getArticlesPublishedBetween(String beginning, String end);
|
||||
// endregion
|
||||
|
||||
}
|
@ -1,15 +1,21 @@
|
||||
package SAE.ApiREST.WebService.service;
|
||||
import SAE.ApiREST.WebService.model.Collect;
|
||||
import SAE.ApiREST.WebService.model.Article;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICollectionService{
|
||||
public List<Collection> getAllCollections();
|
||||
public Collection getCollectionById(long isbn);
|
||||
public List<Collection> getAllCollectionsByName(String name);
|
||||
public List<Collect> getAllCollections();
|
||||
public Collect getCollectionById(long isbn);
|
||||
public List<Collect> getAllCollectionsByName(String name);
|
||||
public void deleteColletionById(long isbn);
|
||||
public void deleteColletionByName(String name);
|
||||
public void deleteAllColletionByName(String name);
|
||||
public void addCollection(Collection collection);
|
||||
public void addCollections(List<Collection> collection);
|
||||
public void modifyCollectionName(Collection collection, String name);
|
||||
public void addCollection(Collect collection);
|
||||
public void addCollections(List<Collect> collection);
|
||||
public void modifyCollectionName(Collect collection, String name);
|
||||
public void modifyCollectionNameById(long isbn, String name);
|
||||
public List<Article> getAllArticles(Collection collection);
|
||||
public void addArticle(Collection collection, Article article);
|
||||
public void deleteArticle(Collection collection, Article article);
|
||||
public List<Article> getAllArticles(Collect collection);
|
||||
public void addArticle(Collect collection, Article article);
|
||||
public void deleteArticle(Collect collection, Article article);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package SAE.ApiREST.WebService.service;
|
||||
|
||||
import SAE.ApiREST.WebService.model.Teacher;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public interface ITeacherService {
|
||||
|
||||
//Todo() by id, by mail, by username, allProf, by date (order), suppression, ajout, FAIRE DES REGIONS!
|
||||
public List<Teacher> getAllTeacher();
|
||||
|
||||
Teacher getTeacherById(Integer id);
|
||||
|
||||
public Teacher getTeacherByUsername(String username);
|
||||
public Teacher getTeacherByMail(String mail);
|
||||
public Teacher getTeacherByDate(String date);
|
||||
public List<Teacher> addTeacher(Teacher t);
|
||||
|
||||
public List<Teacher> deleteTeacher(Integer id);
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
package SAE.ApiREST.WebService.service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import SAE.ApiREST.WebService.model.Article;
|
||||
|
||||
@Service
|
||||
public class StubArticleService implements IArticleService {
|
||||
|
||||
// region GET
|
||||
@Override
|
||||
public List<Article> getAllArticles() {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
articles.add(new Article(
|
||||
"moi",
|
||||
"zaeaeaeazeza",
|
||||
LocalDate.now().minusMonths(2),
|
||||
LocalDate.now().minusMonths(3),
|
||||
false,
|
||||
1)
|
||||
);
|
||||
articles.add(new Article(
|
||||
"eux",
|
||||
"erfdhdh",
|
||||
LocalDate.now().minusMonths(3),
|
||||
LocalDate.now().minusMonths(4),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
articles.add(new Article(
|
||||
"tout ceux qui le veulent",
|
||||
"azersdfgg",
|
||||
LocalDate.now().minusMonths(4),
|
||||
LocalDate.now().minusMonths(5),
|
||||
false,
|
||||
2)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Article getArticlesById(Integer id) {
|
||||
return new Article(
|
||||
"azeaeaze",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesByTitle(String title) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
title,
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesByType(Integer type) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"aeazeazeaz",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
type)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getVisibleArticles() {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getInvisibleArticles() {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
false,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesAddedBefore(String dateAdded) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.parse(dateAdded, DateTimeFormatter.ISO_DATE).minusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesAddedAfter(String dateAdded) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.parse(dateAdded, DateTimeFormatter.ISO_DATE).plusMonths(1),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesAddedBetween(String beginning, String end) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.parse(beginning, DateTimeFormatter.ISO_DATE),
|
||||
LocalDate.now().minusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesPublishedBefore(String datePublished) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.parse(datePublished, DateTimeFormatter.ISO_DATE).plusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesPublishedAfter(String datePublished) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.parse(datePublished, DateTimeFormatter.ISO_DATE).plusMonths(2),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Article> getArticlesPublishedBetween(String beginning, String end) {
|
||||
List<Article> articles = new ArrayList<>();
|
||||
|
||||
articles.add(new Article(
|
||||
"toi",
|
||||
"azezeaea",
|
||||
LocalDate.now().minusMonths(1),
|
||||
LocalDate.parse(end, DateTimeFormatter.ISO_DATE),
|
||||
true,
|
||||
1)
|
||||
);
|
||||
|
||||
return articles;
|
||||
}
|
||||
// endregion
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package SAE.ApiREST.WebService.service;
|
||||
|
||||
import SAE.ApiREST.WebService.model.Teacher;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TeacherServiceStub implements ITeacherService {
|
||||
|
||||
//todo() recevoir collections, ajouter collections, supprimer collections
|
||||
@Override
|
||||
public List<Teacher> getAllTeacher() {
|
||||
List<Teacher> allTeacher = new ArrayList<Teacher>();
|
||||
|
||||
allTeacher.add(new Teacher(1, "12-01-2023", "aline.alipres@gmail.com", "MsGarconManque"));
|
||||
allTeacher.add(new Teacher(2, "20-08-2023", "Viviane.Delvecchio@gmail.com", "MmeMath"));
|
||||
|
||||
return allTeacher;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Teacher getTeacherById(Integer id) {
|
||||
return new Teacher(id, "10-01-2021", "exemple.gmail.com", "testest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher getTeacherByUsername(String username) {
|
||||
return new Teacher(12, "30-08-2020", "dadadou@gmail.com", username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher getTeacherByMail(String mail) {
|
||||
return new Teacher(20, "24-12-2021", mail, "tructruc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teacher getTeacherByDate(String date) {
|
||||
return new Teacher(5, date, "doudouda@gmail.com", "username");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Teacher> addTeacher(Teacher t) {
|
||||
List<Teacher> lteach = new ArrayList<Teacher>();
|
||||
lteach.add(t);
|
||||
return lteach;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Teacher> deleteTeacher(Integer id) {
|
||||
List<Teacher> allTeacher = new ArrayList<Teacher>();
|
||||
|
||||
allTeacher.add(new Teacher(1,"12-01-2023", "aline.alipres@gmail.com", "MsGarconManque"));
|
||||
allTeacher.add(new Teacher(2, "20-08-2023", "Viviane.Delvecchio@gmail.com", "MmeMath"));
|
||||
|
||||
allTeacher.remove(getTeacherById(id));
|
||||
return allTeacher;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue