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
import java.util.Locale; | |
import java.util.Scanner; | |
public class Atletas { | |
public static void main(String[] args) { | |
Locale.setDefault(Locale.US); | |
Scanner teclado = new Scanner(System.in); | |
System.out.println("Digite a quantidade de atletas: "); | |
int quantidadeAtletas = teclado.nextInt(); |
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
import java.util.Locale; | |
import java.util.Scanner; | |
public class DesafioImpostoJava { | |
public static void main(String[] args) { | |
Locale.setDefault(Locale.US); | |
Scanner entradaDados = new Scanner(System.in); | |
System.out.println("Digite sua renda anual com salário: "); | |
double salarioAnual = entradaDados.nextDouble(); |
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
package br.com.marcioviana.gerenciadordemultas.controler; | |
import br.com.marcioviana.gerenciadordemultas.model.Cliente; | |
import br.com.marcioviana.gerenciadordemultas.repository.ClienteRepository; | |
import jakarta.validation.Valid; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.PostMapping; | |
import org.springframework.web.bind.annotation.RequestBody; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; |
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
@PostMapping | |
public ResponseEntity<Void> cadastrar(@RequestBody @Valid ClienteRequest clienteRequest, UriComponentsBuilder uriComponentsBuilder){ | |
Cliente novoCliente = clienteRequest.paraCliente(); | |
clienteRepository.save(novoCliente); | |
URI caminho = uriComponentsBuilder.path("/clientes/{id}").buildAndExpand(novoCliente.getId()).toUri(); | |
return ResponseEntity.created(caminho).build(); | |
} |
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
@RestController | |
@RequestMapping("/clientes") | |
public class ClienteController { | |
private final ClienteRepository clienteRepository; | |
public ClienteController(ClienteRepository clienteRepository) { | |
this.clienteRepository = clienteRepository; | |
} |
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
package br.com.marcioviana.gerenciadordemultas.controler; | |
import br.com.marcioviana.gerenciadordemultas.model.Cliente; | |
import jakarta.validation.constraints.Email; | |
import jakarta.validation.constraints.NotBlank; | |
import jakarta.validation.constraints.NotNull; | |
import jakarta.validation.constraints.Positive; | |
import org.hibernate.validator.constraints.Length; | |
import org.hibernate.validator.constraints.br.CPF; |
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
package br.com.marcioviana.gerenciadordemultas.repository; | |
import br.com.marcioviana.gerenciadordemultas.model.Cliente; | |
import org.springframework.data.jpa.repository.JpaRepository; | |
public interface ClienteRepository extends JpaRepository<Cliente, Long> { | |
} |
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
package br.com.marcioviana.gerenciadordemultas.controler; | |
import br.com.marcioviana.gerenciadordemultas.model.Cliente; | |
import br.com.marcioviana.gerenciadordemultas.repository.ClienteRepository; | |
import jakarta.validation.Valid; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.PostMapping; | |
import org.springframework.web.bind.annotation.RequestBody; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; |
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
package br.com.marcioviana.gerenciadordemultas.model; | |
import jakarta.persistence.*; | |
@Entity | |
public class Cliente { | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
private Long id; |