-
-
Save parzibyte/76361f9212119b224a00fa9a6111b55d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.parzibyte.api; | |
import org.springframework.web.bind.annotation.*; | |
import org.springframework.beans.factory.annotation.Autowired; | |
@RestController | |
@RequestMapping(path = "/alumnos") | |
@CrossOrigin(origins = "http://localhost") | |
public class AlumnosController { | |
@Autowired | |
private AlumnosRepository alumnosRepository; | |
@RequestMapping(value = "/crear", method = RequestMethod.POST) | |
public Alumno crearAlumno(@RequestBody Alumno alumno) { | |
return alumnosRepository.save(alumno); | |
} | |
@RequestMapping(value = "/obtener", method = RequestMethod.GET) | |
public Iterable<Alumno> obtenerTodos() { | |
return alumnosRepository.findAll(); | |
} | |
@RequestMapping(value = "/eliminar/{id}", method = RequestMethod.DELETE) | |
public boolean eliminar(@PathVariable() Long id) { | |
alumnosRepository.deleteById(id); | |
return true; | |
} | |
@RequestMapping(value = "/actualizar", method = RequestMethod.PUT) | |
public Alumno editar(@RequestBody Alumno alumno) { | |
return alumnosRepository.save(alumno); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment