-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: criar e associar cartao a propostas elegiveis
- Loading branch information
1 parent
6fc07e4
commit 895bd03
Showing
28 changed files
with
490 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
...sefinanceira/AnaliseFinanceiraClient.java → ...sefinanceira/AnaliseFinanceiraClient.java
This file contains 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
2 changes: 1 addition & 1 deletion
2
...efinanceira/AnaliseFinanceiraRequest.java → ...efinanceira/AnaliseFinanceiraRequest.java
This file contains 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
2 changes: 1 addition & 1 deletion
2
...financeira/AnaliseFinanceiraResponse.java → ...financeira/AnaliseFinanceiraResponse.java
This file contains 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
2 changes: 1 addition & 1 deletion
2
...inanceira/AnaliseFinanceiraResultado.java → ...inanceira/AnaliseFinanceiraResultado.java
This file contains 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
14 changes: 14 additions & 0 deletions
14
src/main/java/br/com/zupacademy/william/proposta/gateway/cartao/AvisoGatewayResponse.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
public class AvisoGatewayResponse { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Long idCartao; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/br/com/zupacademy/william/proposta/gateway/cartao/BloqueioGatewayResponse.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
import br.com.zupacademy.william.proposta.proposta.cartao.bloqueio.Bloqueio; | ||
|
||
public class BloqueioGatewayResponse { | ||
|
||
private Long id; | ||
private Long idCartao; | ||
|
||
public Bloqueio toModel() { | ||
return new Bloqueio(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/br/com/zupacademy/william/proposta/gateway/cartao/CartaoClient.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
@FeignClient(name = "cartoes", url = "http://localhost:8888/api/cartoes") | ||
public interface CartaoClient { | ||
|
||
@PostMapping | ||
GeracaoCartaoGatewayResponse cadastrarCartao(@RequestBody GeracaoCartaoRequestGateway geracaoCartaoRequestGateway); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/br/com/zupacademy/william/proposta/gateway/cartao/CarteiraGatewayResponse.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
public class CarteiraGatewayResponse { | ||
|
||
private Long id; | ||
|
||
private Long idCartao; | ||
} |
44 changes: 44 additions & 0 deletions
44
.../java/br/com/zupacademy/william/proposta/gateway/cartao/GeracaoCartaoGatewayResponse.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
import br.com.zupacademy.william.proposta.proposta.cartao.Cartao; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public class GeracaoCartaoGatewayResponse { | ||
|
||
private String id; | ||
private LocalDateTime emitidoEm; | ||
private String titular; | ||
private String idProposta; | ||
private Long limite; | ||
private List<BloqueioGatewayResponse> bloqueios; | ||
private List<AvisoGatewayResponse> avisos; | ||
private List<CarteiraGatewayResponse> carteiras; | ||
private List<ParcelaGatewayResponse> parcelas; | ||
private VencimentoGatewayResponse vencimento; | ||
private String renegociacao; | ||
|
||
public GeracaoCartaoGatewayResponse(String id, LocalDateTime emitidoEm, String titular, String idProposta, | ||
Long limite, List<BloqueioGatewayResponse> bloqueios, | ||
List<AvisoGatewayResponse> avisos, List<CarteiraGatewayResponse> carteiras, | ||
List<ParcelaGatewayResponse> parcelas, VencimentoGatewayResponse vencimento, | ||
String renegociacao) { | ||
this.id = id; | ||
this.emitidoEm = emitidoEm; | ||
this.titular = titular; | ||
this.idProposta = idProposta; | ||
this.limite = limite; | ||
this.bloqueios = bloqueios; | ||
this.avisos = avisos; | ||
this.carteiras = carteiras; | ||
this.parcelas = parcelas; | ||
this.vencimento = vencimento; | ||
this.renegociacao = renegociacao; | ||
} | ||
|
||
public Cartao toModel() { | ||
return new Cartao(this.id, this.emitidoEm, this.titular, this.limite, this.renegociacao, | ||
Long.parseLong(this.idProposta), this.vencimento.toModel()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...n/java/br/com/zupacademy/william/proposta/gateway/cartao/GeracaoCartaoRequestGateway.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
public class GeracaoCartaoRequestGateway { | ||
|
||
private String idProposta; | ||
private String documento; | ||
private String nome; | ||
|
||
public GeracaoCartaoRequestGateway(String idProposta, String documento, String nome) { | ||
this.idProposta = idProposta; | ||
this.documento = documento; | ||
this.nome = nome; | ||
} | ||
|
||
public String getIdProposta() { | ||
return idProposta; | ||
} | ||
|
||
public String getDocumento() { | ||
return documento; | ||
} | ||
|
||
public String getNome() { | ||
return nome; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/br/com/zupacademy/william/proposta/gateway/cartao/ParcelaGatewayResponse.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
public class ParcelaGatewayResponse { | ||
|
||
private Long id; | ||
|
||
private Long idCartao; | ||
} |
23 changes: 23 additions & 0 deletions
23
...ain/java/br/com/zupacademy/william/proposta/gateway/cartao/VencimentoGatewayResponse.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package br.com.zupacademy.william.proposta.gateway.cartao; | ||
|
||
import br.com.zupacademy.william.proposta.proposta.cartao.vencimento.Vencimento; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class VencimentoGatewayResponse { | ||
|
||
private String id; | ||
private int dia; | ||
private LocalDateTime dataCriacao; | ||
|
||
public VencimentoGatewayResponse(String id, int dia, LocalDateTime dataCriacao) { | ||
this.id = id; | ||
this.dia = dia; | ||
this.dataCriacao = dataCriacao; | ||
} | ||
|
||
public Vencimento toModel() { | ||
return new Vencimento(id, dia, LocalDateTime.now()); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
11 changes: 10 additions & 1 deletion
11
src/main/java/br/com/zupacademy/william/proposta/proposta/PropostaRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
package br.com.zupacademy.william.proposta.proposta; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface PropostaRepository extends JpaRepository<Proposta, Long> { | ||
import java.util.List; | ||
|
||
public interface PropostaRepository extends | ||
JpaRepository<Proposta, Long>, | ||
JpaSpecificationExecutor<Proposta> { | ||
|
||
boolean existsByDocumento(String documento); | ||
|
||
@Query("SELECT p from Proposta p left join Cartao c on p.id = c.idProposta where c.id is null and p.propostaEstado = 'ELEGIVEL'") | ||
List<Proposta> buscarPropostasComStatusElegivelQueNaoPossuemCartao(); | ||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/br/com/zupacademy/william/proposta/proposta/cartao/Cartao.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package br.com.zupacademy.william.proposta.proposta.cartao; | ||
|
||
import br.com.zupacademy.william.proposta.proposta.cartao.aviso.Aviso; | ||
import br.com.zupacademy.william.proposta.proposta.cartao.bloqueio.Bloqueio; | ||
import br.com.zupacademy.william.proposta.proposta.cartao.carteira.Carteira; | ||
import br.com.zupacademy.william.proposta.proposta.cartao.parcela.Parcela; | ||
import br.com.zupacademy.william.proposta.proposta.cartao.vencimento.Vencimento; | ||
|
||
import javax.persistence.*; | ||
import java.time.LocalDateTime; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@Entity | ||
public class Cartao { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String numero; | ||
private LocalDateTime emitidoEm; | ||
private String titular; | ||
private Long limite; | ||
private String renegociacao; | ||
private Long idProposta; | ||
|
||
@OneToMany(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "idCartao") | ||
private List<Bloqueio> bloqueios; | ||
|
||
@OneToMany(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "idCartao") | ||
private List<Aviso> avisos; | ||
|
||
@OneToMany(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "idCartao") | ||
private List<Carteira> carteiras; | ||
|
||
@OneToMany(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "idCartao") | ||
private List<Parcela> parcelas; | ||
|
||
//TODO | ||
// fazer relacionamento para salvar o id do cartao no vencimento, onetomany foi workaround | ||
@OneToMany(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "idCartao") | ||
private List<Vencimento> vencimento; | ||
|
||
// public Cartao(String numero, LocalDateTime emitidoEm, String titular, Long limite, String renegociacao, | ||
// Long idProposta, List<Bloqueio> bloqueios, List<Aviso> avisos, List<Carteira> carteiras, | ||
// List<Parcela> parcelas, Vencimento vencimento) { | ||
// this.numero = numero; | ||
// this.emitidoEm = emitidoEm; | ||
// this.titular = titular; | ||
// this.limite = limite; | ||
// this.renegociacao = renegociacao; | ||
// this.idProposta = idProposta; | ||
// this.bloqueios = bloqueios; | ||
// this.avisos = avisos; | ||
// this.carteiras = carteiras; | ||
// this.parcelas = parcelas; | ||
// this.vencimento = vencimento; | ||
// } | ||
|
||
//CONSTRUTOR TEMPORARIO | ||
//TODO | ||
// Refatorar para nao receber idProposta e usar o cascade da classe Proposta | ||
public Cartao(String numero, LocalDateTime emitidoEm, String titular, Long limite, String renegociacao, | ||
Long idProposta, Vencimento vencimento) { | ||
this.numero = numero; | ||
this.emitidoEm = emitidoEm; | ||
this.titular = titular; | ||
this.limite = limite; | ||
this.renegociacao = renegociacao; | ||
this.idProposta = idProposta; | ||
this.vencimento = Collections.singletonList(vencimento); | ||
} | ||
|
||
@Deprecated | ||
public Cartao() { | ||
} | ||
} |
Oops, something went wrong.