doc: documentation
This commit is contained in:
@@ -2,10 +2,8 @@ package myapi.api.Controller;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import myapi.api.Model.Task;
|
import myapi.api.Model.Task;
|
||||||
import myapi.api.Repository.TaskRepository;
|
|
||||||
import myapi.api.Service.TaskService;
|
import myapi.api.Service.TaskService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -15,6 +13,10 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe servant de point d'entrée pour les objets Tâches
|
||||||
|
* TaskController
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/task")
|
@RequestMapping("/task")
|
||||||
public class TaskController {
|
public class TaskController {
|
||||||
@@ -22,21 +24,39 @@ public class TaskController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère toutes les tâches de la bdd
|
||||||
|
* @return Une liste de Task
|
||||||
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public List<Task> getAllTasks() {
|
public List<Task> getAllTasks() {
|
||||||
return taskService.getAllTasks();
|
return taskService.getAllTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute une nouvelle tâche à la bdd
|
||||||
|
* @param task L'objet tâche que l'on veut ajouter
|
||||||
|
* @return La tâche créée
|
||||||
|
*/
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public Task addTask(@RequestBody Task task) {
|
public Task addTask(@RequestBody Task task) {
|
||||||
return taskService.addTask(task);
|
return taskService.addTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modifie une tâche de la bdd
|
||||||
|
* @param task La tâche que l'on veut modifier. Il faut que son id soit déjà présent
|
||||||
|
* @return La tâche créée
|
||||||
|
*/
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
public Task updateTask(@RequestBody Task task) {
|
public Task updateTask(@RequestBody Task task) {
|
||||||
return taskService.updateTask(task);
|
return taskService.updateTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supprime une tâche de la bdd
|
||||||
|
* @param idTask L'id de la tâche
|
||||||
|
*/
|
||||||
@DeleteMapping("/delete/{id}")
|
@DeleteMapping("/delete/{id}")
|
||||||
public void deleteTask(@PathVariable("id") int idTask) {
|
public void deleteTask(@PathVariable("id") int idTask) {
|
||||||
taskService.deleteTask(idTask);
|
taskService.deleteTask(idTask);
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package myapi.api.Model.Enums;
|
package myapi.api.Model.Enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumération des différents status possibles pour une tâche
|
||||||
|
* Status
|
||||||
|
*/
|
||||||
public enum Status {
|
public enum Status {
|
||||||
EnCours,
|
En_cours,
|
||||||
Termine,
|
Termine,
|
||||||
EnRetard
|
En_retard,
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
package myapi.api.Model;
|
package myapi.api.Model;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.GenerationType;
|
import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe mappée à la table task de la bdd
|
||||||
|
* Task
|
||||||
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "task")
|
@Table(name = "task")
|
||||||
public class Task {
|
public class Task {
|
||||||
@@ -22,6 +25,7 @@ public class Task {
|
|||||||
private Integer priority_task;
|
private Integer priority_task;
|
||||||
private Integer id_group;
|
private Integer id_group;
|
||||||
|
|
||||||
|
/* --- GETTERS ET SETTER --- */
|
||||||
|
|
||||||
public int getId_task() {
|
public int getId_task() {
|
||||||
return id_task;
|
return id_task;
|
||||||
|
|||||||
@@ -4,5 +4,9 @@ import myapi.api.Model.Task;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository Jpa permettant la persistance
|
||||||
|
* TaskRepository
|
||||||
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface TaskRepository extends JpaRepository<Task, Integer> {}
|
public interface TaskRepository extends JpaRepository<Task, Integer> {}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package myapi.api.Service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import myapi.api.Model.Task;
|
import myapi.api.Model.Task;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package myapi.api.Service;
|
package myapi.api.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import myapi.api.Model.Task;
|
import myapi.api.Model.Task;
|
||||||
import myapi.api.Repository.TaskRepository;
|
import myapi.api.Repository.TaskRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -13,16 +12,25 @@ public class TaskServiceImpl implements TaskService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TaskRepository taskRepository;
|
private TaskRepository taskRepository;
|
||||||
|
|
||||||
|
/** (non-Javadoc)
|
||||||
|
* @see myapi.api.Service.TaskService#getAllTasks()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Task> getAllTasks() {
|
public List<Task> getAllTasks() {
|
||||||
return taskRepository.findAll();
|
return taskRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** (non-Javadoc)
|
||||||
|
* @see myapi.api.Service.TaskService#addTask(myapi.api.Model.Task)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Task addTask(Task task) {
|
public Task addTask(Task task) {
|
||||||
return taskRepository.save(task);
|
return taskRepository.save(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** (non-Javadoc)
|
||||||
|
* @see myapi.api.Service.TaskService#updateTask(myapi.api.Model.Task)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Task updateTask(Task task) {
|
public Task updateTask(Task task) {
|
||||||
Task dbTask = taskRepository.findById(task.getId_task()).get();
|
Task dbTask = taskRepository.findById(task.getId_task()).get();
|
||||||
@@ -35,6 +43,9 @@ public class TaskServiceImpl implements TaskService {
|
|||||||
return taskRepository.save(dbTask);
|
return taskRepository.save(dbTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** (non-Javadoc)
|
||||||
|
* @see myapi.api.Service.TaskService#deleteTask(int)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteTask(int taskId) {
|
public void deleteTask(int taskId) {
|
||||||
taskRepository.deleteById(taskId);
|
taskRepository.deleteById(taskId);
|
||||||
|
|||||||
Reference in New Issue
Block a user