Skip to content

Instantly share code, notes, and snippets.

@thiagolenz
Last active October 11, 2020 13:15
Show Gist options
  • Save thiagolenz/4a2ec93495194ff1ce52acff28d35dcd to your computer and use it in GitHub Desktop.
Save thiagolenz/4a2ec93495194ff1ce52acff28d35dcd to your computer and use it in GitHub Desktop.
Pessoa.java
@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