File tree Expand file tree Collapse file tree 3 files changed +45
-16
lines changed
testeSantanderWay/src/main/java/br/com/testesantanderway Expand file tree Collapse file tree 3 files changed +45
-16
lines changed Original file line number Diff line number Diff line change 1+ package br .com .testesantanderway .controller ;
2+
3+
4+ import br .com .testesantanderway .dto .ClienteDTO ;
5+ import br .com .testesantanderway .modelo .Cliente ;
6+ import br .com .testesantanderway .repository .ClienteRepository ;
7+ import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .web .bind .annotation .PathVariable ;
9+ import org .springframework .web .bind .annotation .RequestMapping ;
10+ import org .springframework .web .bind .annotation .RestController ;
11+ import java .util .List ;
12+
13+
14+ @ RestController
15+ public class LoginCliente {
16+ @ Autowired
17+ private ClienteRepository clienteRepository ;
18+
19+ @ RequestMapping ("/clientes" )
20+ //@PostConstruct
21+ public List <ClienteDTO > dadosLoginCliente (){
22+ List <Cliente > clientes = (List <Cliente >) clienteRepository .findAll ();
23+
24+ return ClienteDTO .converter (clientes );
25+ }
26+ // List<Cliente> cliente = new ArrayList<>();
27+ // cliente.add(new Cliente(1L, "jonatas", "[email protected] ", "zupper")); 28+ // repository.saveAll(cliente);
29+ // }
30+
31+ // @GetMapping("/logincliente/{nome}")
32+ // public Cliente getClienteByName(@PathVariable String nome) {
33+ // return repository.findByNome(nome);
34+ // }
35+ }
Original file line number Diff line number Diff line change 11package br .com .testesantanderway .dto ;
22
33import br .com .testesantanderway .modelo .Cliente ;
4- import org .springframework .data .domain .Page ;
54
6- import java .time . LocalDateTime ;
5+ import java .util . List ;
76
87public class ClienteDTO {
98 private String nome ;
109 private String email ;
11- private LocalDateTime dataCriacao ;
1210
13- public ClienteDTO (Cliente cliente ){
14- this .nome = cliente .getNome ();
15- this .email = cliente .getEmail ();
11+ public ClienteDTO (String nome , String email ){
12+ this .nome = nome ;
13+ this .email = email ;
14+ }
15+
16+ public static List <ClienteDTO > converter (List <Cliente > cliente ) {
17+ return new ClienteDTO (cliente .getNome (), cliente .getEmail ());
1618 }
1719
1820 public String getNome () {
@@ -22,8 +24,4 @@ public String getNome() {
2224 public String getEmail () {
2325 return email ;
2426 }
25-
26- public static Page <ClienteDTO > converter (Page <Cliente > clientes ) {
27- return clientes .map (ClienteDTO ::new );
28- }
2927}
Original file line number Diff line number Diff line change 11package br .com .testesantanderway .repository ;
22
33import br .com .testesantanderway .modelo .Cliente ;
4- import org .springframework .data .domain .Page ;
5- import org .springframework .data .domain .Pageable ;
64import org .springframework .data .solr .repository .SolrCrudRepository ;
7- import java .util .Optional ;
85
9- public interface ClienteRepository extends SolrCrudRepository <Cliente , String > {
10- Page <Cliente > findByNome (String nome , Pageable paginacao );
11- Optional <Cliente > findByEmail (String email );
6+ public interface ClienteRepository extends SolrCrudRepository <Cliente , Long > {
7+ //Cliente findByNome(String nome);
128}
You can’t perform that action at this time.
0 commit comments