feat: Get de toutes les tasks de la database
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
package myapi.api.Controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import myapi.api.Data.DAO.TaskDao;
|
||||
import myapi.api.Data.Repository.TaskRepository;
|
||||
import myapi.api.Model.Task;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/task")
|
||||
public class TaskController {
|
||||
@Autowired
|
||||
private TaskDao taskDao;
|
||||
private final TaskRepository taskRepository;
|
||||
|
||||
public TaskController(TaskRepository repository){
|
||||
this.taskRepository = repository;
|
||||
}
|
||||
|
||||
@GetMapping("")
|
||||
public String getTasks(){
|
||||
return this.taskDao.getTasks().getFirst();
|
||||
@GetMapping
|
||||
public List<Task> getTasks(){
|
||||
return this.taskRepository.findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user