add to do list
This commit is contained in:
parent
bb5cd4b57b
commit
4f7834a9a6
|
@ -160,7 +160,7 @@ public class MembreController {
|
|||
membreRepo.deleteById(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !");
|
||||
} catch (Exception e) {
|
||||
MembreNotFoundException membreNotFoundException = new membreNotFoundException(id);
|
||||
MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package fr.organizee.controller;
|
||||
|
||||
import fr.organizee.model.TodoList;
|
||||
import fr.organizee.model.Team;
|
||||
import fr.organizee.repository.TodoListRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -19,6 +20,7 @@ public class TodoListController {
|
|||
@Autowired
|
||||
private TodoListRepository todolistRepo;
|
||||
|
||||
|
||||
@GetMapping(value = "/all")
|
||||
public ResponseEntity<?> getAll(){
|
||||
List<TodoList> liste = null;
|
||||
|
@ -32,6 +34,23 @@ public class TodoListController {
|
|||
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}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> deleteTodolist(@PathVariable int id){
|
||||
|
|
|
@ -9,7 +9,8 @@ import org.springframework.stereotype.Repository;
|
|||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TacheRepository extends JpaRepository<Tache, Integer> {
|
||||
public interface
|
||||
TacheRepository extends JpaRepository<Tache, Integer> {
|
||||
|
||||
// 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)
|
||||
|
|
|
@ -17,7 +17,8 @@ import fr.organizee.repository.MembreRepository;
|
|||
import fr.organizee.security.JwtTokenProvider;
|
||||
|
||||
@Service
|
||||
public class MembreServiceImpl implements MembreService {
|
||||
public class
|
||||
MembreServiceImpl implements MembreService {
|
||||
|
||||
@Autowired
|
||||
private MembreRepository membreRepository; // permet communication avec la BD
|
||||
|
|
Loading…
Reference in New Issue