Created
January 4, 2023 17:00
-
-
Save lucaspmarra/db1cb2b667c4b5c97230f7e8d805b25d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Java: | |
| @GetMapping("/users/nome/{nome}") | |
| @Query(value = "SELECT * FROM USUARIO WHERE NOME LIKE '%:nome%'", nativeQuery = true) | |
| List<User> getUserByName(@PathVariable(value = "nome") String nome) throws ResourceNotFoundException { | |
| List<User> users = userRepository.findByNome(nome); | |
| if (users.isEmpty()) { | |
| throw new ResourceNotFoundException("User not found for this name: " + nome); | |
| } | |
| return users; | |
| } | |
| Response: | |
| [{"id":1000078,"sigla":"email@gmail.com.br","nome":"LUCAS PAULINO MARRA"}, | |
| {"id":100001635,"sigla":"sigla","nome":"LUCAS PAULINO MARRA"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment