Controller
Para crear nuestros servicios creamos el paquete com.tutosoftware.manager.controllerCreamos la clase UsuarioController
package com.tutosoftware.manager.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tutosoftware.manager.model.Usuario;
import com.tutosoftware.manager.service.UsuarioService;
@RestController
@RequestMapping(value="/api/v1")
@CrossOrigin(origins= {"*"})
public class UsuarioController {
@Autowired
private UsuarioService usuarioService;
@GetMapping("/usuario/{email}")
public ResponseEntity<Usuario> getUsuarioById(@PathVariable("email") String email){
Usuario usuario= usuarioService.getUsuario(email).orElseThrow();
return new ResponseEntity<Usuario>(usuario, HttpStatus.OK);
}
}