Last active
October 11, 2020 13:15
-
-
Save thiagolenz/4a2ec93495194ff1ce52acff28d35dcd to your computer and use it in GitHub Desktop.
Pessoa.java
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
@Entity | |
public class Pessoa { | |
@Id private Long id; | |
private String nome; | |
// dados do endereco | |
private String rua; | |
private String numero; | |
private String bairro; | |
private String cep; | |
private String cidade; | |
private String uf; | |
} | |
@Controller | |
@RequestMapping("/pessoa") | |
public class PessoaAPI { | |
@Autowired private PessoaService pessoaService; | |
@PostMapping | |
@ResponseBody | |
public Pessoa save (@RequestBody Pessoa pessoa) { | |
return pessoaService.save (pessoa); | |
} | |
} | |
@Service | |
public class PessoaService { | |
@Autowired private PessoaRepository pessoaRepository; | |
public Pessoa save (Pessoa pessoa) { | |
return pessoaRepository.save (pessoa); | |
} | |
} | |
@Repository | |
public class PessoaRepository extends JpaRepository<Pessoa, Long> {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment