Merge pull request #46 from HediMjid/isa

add to do list
This commit is contained in:
Hédi 2022-02-27 18:04:20 +01:00 committed by GitHub
commit 69483609d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package fr.organizee.controller; package fr.organizee.controller;
import fr.organizee.model.TodoList; import fr.organizee.model.TodoList;
import fr.organizee.model.Team;
import fr.organizee.repository.TodoListRepository; import fr.organizee.repository.TodoListRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -19,6 +20,7 @@ public class TodoListController {
@Autowired @Autowired
private TodoListRepository todolistRepo; private TodoListRepository todolistRepo;
@GetMapping(value = "/all") @GetMapping(value = "/all")
public ResponseEntity<?> getAll(){ public ResponseEntity<?> getAll(){
List<TodoList> liste = null; List<TodoList> liste = null;
@ -32,6 +34,23 @@ public class TodoListController {
return ResponseEntity.status(HttpStatus.OK).body(liste); return ResponseEntity.status(HttpStatus.OK).body(liste);
} }
//Ajoute une nouvelle ToDoList
@PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json")
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> addTodolist(@RequestBody TodoList todolist, @PathVariable Integer team_id) {
TodoList resultTodolist = null;
try {
Team team = new Team();
team.setId(team_id);
todolist.setTeam(team);
resultTodolist = todolistRepo.saveAndFlush(todolist);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
return ResponseEntity.status(HttpStatus.CREATED).body(resultTodolist);
}
@DeleteMapping(value = "/delete/{id}") @DeleteMapping(value = "/delete/{id}")
//@PreAuthorize("hasRole('ROLE_PARENT')") //@PreAuthorize("hasRole('ROLE_PARENT')")
public ResponseEntity<?> deleteTodolist(@PathVariable int id){ public ResponseEntity<?> deleteTodolist(@PathVariable int id){

View File

@ -9,7 +9,8 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@Repository @Repository
public interface TacheRepository extends JpaRepository<Tache, Integer> { public interface
TacheRepository extends JpaRepository<Tache, Integer> {
// N'est plus utilisé normalement // N'est plus utilisé normalement
@Query(value = "select * from todo_list, tache where todo_list.team_id = :team_id and todo_list.id = tache.todolist_id", nativeQuery = true) @Query(value = "select * from todo_list, tache where todo_list.team_id = :team_id and todo_list.id = tache.todolist_id", nativeQuery = true)

View File

@ -17,7 +17,8 @@ import fr.organizee.repository.MembreRepository;
import fr.organizee.security.JwtTokenProvider; import fr.organizee.security.JwtTokenProvider;
@Service @Service
public class MembreServiceImpl implements MembreService { public class
MembreServiceImpl implements MembreService {
@Autowired @Autowired
private MembreRepository membreRepository; // permet communication avec la BD private MembreRepository membreRepository; // permet communication avec la BD