Sobre o projeto | Tecnologias | Iniciando | Funcionalidades
Banco BlueBank é projeto final referente ao treinamento sobre BACK-END em Java ofertado pelo Banco Pan cuja Parceria Gama Academy!
Para ver a DOCUMENTAÇÃO api, clique aqui: BlueBank DOC da API
Para ver a api, clique aqui: BlueBank API
Tecnologias, Framework e Metodologias utilizadas:
- Java 11
- Versionamento de Código com Git e GitHub
- Metodologia Agile
- Design Pattern DTO -Data Transfer Objects-
- Spring Boot
- Spring Boot: Spring Data
- Spring Boot: Spring Security OAuth
- Autenticação com JWT
- Estratégia de Paginação
- MAVEN
- Swagger
- MySQL
- Modelo relacional
- AWS
- AWS Lambda
- AWS ApiGateway
- Testes Unitário e de Integração
-
Entidade entitulada Agencia
-
Type:
object
-
path: #/definitions/ Agencia
-
Properties
- agencia
- Campo referente nome juridico da Agencia
- Type:
string
- path: #/definitions/ Agencia/properties/agencia
- dataCadastro
- Campo referente data da criação
- Type:
string
- path: #/definitions/ Agencia/properties/dataCadastro
- String format must be a "date-time"
- id
- Campo ID
- Type:
integer
- path: #/definitions/ Agencia/properties/id
- nome
- Campo referente nome fantasia da Agencia
- Type:
string
- path: #/definitions/ Agencia/properties/nome
- agencia
- Type:
object
- path: #/definitions/AgenciaOutputDTO
- Properties
- agencia
- Type:
string
- path: #/definitions/AgenciaOutputDTO/properties/agencia
- Type:
- id
- Type:
integer
- path: #/definitions/AgenciaOutputDTO/properties/id
- Type:
- nome
- Type:
string
- path: #/definitions/AgenciaOutputDTO/properties/nome
- Type:
- agencia
- Entidade entitulada Conta
- Type:
object
- path: #/definitions/Conta
- Properties
- agencia
- Campo referente OBJETO AGENCIA
- path: #/definitions/Conta/properties/agencia
- $ref: [#/definitions/Agencia] (#/definitions/Agencia)
- correntista
- Campo referente OBJETO CORRENTISTA
- path: #/definitions/Conta/properties/correntista
- $ref: [#/definitions/Correntista] (#/definitions/Correntista)
- dataCadastro
- Type:
string
- path: #/definitions/Conta/properties/dataCadastro
- String format must be a "date-time"
- Type:
- numeroConta
- Campo ID
- Type:
integer
- path: #/definitions/Conta/properties/numeroConta
- tipoConta
required
- Campo referente tipo de conta no momento do cadastro a ser cadastrado
- Type:
string
- path: #/definitions/Conta/properties/tipoConta
- agencia
- Type:
object
- path: #/definitions/ContaOutputDTO
- Properties
- agencia
- path: #/definitions/ContaOutputDTO/properties/agencia
- $ref: [#/definitions/AgenciaOutputDTO] (#/definitions/AgenciaOutputDTO)
- correntista
- path: #/definitions/ContaOutputDTO/properties/correntista
- $ref: [#/definitions/CorrentistaOutputDTO] (#/definitions/CorrentistaOutputDTO)
- dataCadastro
- Type:
string
- path: #/definitions/ContaOutputDTO/properties/dataCadastro
- String format must be a "date-time"
- Type:
- digito
- Type:
string
- path: #/definitions/ContaOutputDTO/properties/digito
- Type:
- numeroConta
- Type:
integer
- path: #/definitions/ContaOutputDTO/properties/numeroConta
- Type:
- numeroContaCompleta
- Type:
string
- path: #/definitions/ContaOutputDTO/properties/numeroContaCompleta
- Type:
- tipoConta
- Type:
string
- path: #/definitions/ContaOutputDTO/properties/tipoConta
- Type:
- agencia
- Entidade entitulada ContatoCliente
- Type:
object
- path: #/definitions/ContatoCliente
- Properties
- dataCadastro
- Campo referente data de criação
- Type:
string
- path: #/definitions/ContatoCliente/properties/dataCadastro
- String format must be a "date-time"
- email
required
- Campo referente e-mail
- Type:
string
- path: #/definitions/ContatoCliente/properties/email
- id
- Campo referente ID
- Type:
integer
- path: #/definitions/ContatoCliente/properties/id
- infoRecado
required
- Campo referente Informações para recados
- Type:
string
- path: #/definitions/ContatoCliente/properties/infoRecado
- telefone
required
- Campo referente ao telefone
- Type:
string
- path: #/definitions/ContatoCliente/properties/telefone
- dataCadastro
- Entidade entitulada Correntista
- Type:
object
- path: #/definitions/Correntista
- Properties
- cnpj
- Campo CNPJ
- Type:
string
- path: #/definitions/Correntista/properties/cnpj
- contatos
- Campo Objeto Contato relacionado Correntista
- Type:
array
- path: #/definitions/Correntista/properties/contatos
- Items
- path: #/definitions/Correntista/properties/contatos/items
- $ref: [#/definitions/ContatoCliente] (#/definitions/ContatoCliente)
- cpf
- _ Campo CPF_
- Type:
string
- path: #/definitions/Correntista/properties/cpf
- dataCadastro
- Campo da data ao criar Correntista
- Type:
string
- path: #/definitions/Correntista/properties/dataCadastro
- String format must be a "date-time"
- emailValidacao
- _ Campo E-mail para notificar movimentação_
- Type:
string
- path: #/definitions/Correntista/properties/emailValidacao
- enderecos
- Campo Endereço do correntista
- Type:
array
- path: #/definitions/Correntista/properties/enderecos
- Items
- path: #/definitions/Correntista/properties/enderecos/items
- $ref: [#/definitions/Endereco] (#/definitions/Endereco)
- id
- Campo ID
- Type:
integer
- path: #/definitions/Correntista/properties/id
- nome
required
- Campo Nome da pessoa
- Type:
string
- path: #/definitions/Correntista/properties/nome
- rg
- Campo RG
- Type:
string
- path: #/definitions/Correntista/properties/rg
- sms
- Type:
string
- path: #/definitions/Correntista/properties/sms
- Type:
- tipoPessoa
required
- Campo Tipo de Pessoa: Fisica ou Juridica
- Type:
string
- path: #/definitions/Correntista/properties/tipoPessoa
- cnpj
- Type:
object
- path: #/definitions/CorrentistaOutputDTO
- Properties
- cnpj
- Type:
string
- path: #/definitions/CorrentistaOutputDTO/properties/cnpj
- Type:
- cpf
- Type:
string
- path: #/definitions/CorrentistaOutputDTO/properties/cpf
- Type:
- id
- Type:
integer
- path: #/definitions/CorrentistaOutputDTO/properties/id
- Type:
- nome
- Type:
string
- path: #/definitions/CorrentistaOutputDTO/properties/nome
- Type:
- rg
- Type:
string
- path: #/definitions/CorrentistaOutputDTO/properties/rg
- Type:
- cnpj
- Entidade entitulada Endereco
- Type:
object
- path: #/definitions/Endereco
- Properties
- bairro
required
- Campo bairro
- Type:
string
- path: #/definitions/Endereco/properties/bairro
- cep
required
- Campo CEP
- Type:
string
- path: #/definitions/Endereco/properties/cep
- cidade
required
- Campo cidade
- Type:
string
- path: #/definitions/Endereco/properties/cidade
- complemento
- Campo complemento referente cadastro do endereço
- Type:
string
- path: #/definitions/Endereco/properties/complemento
- dataCadastro
- Campo referente data da criação
- Type:
string
- path: #/definitions/Endereco/properties/dataCadastro
- String format must be a "date-time"
- estado
required
- Campo estado
- Type:
string
- path: #/definitions/Endereco/properties/estado
- id
- Campo referente ID
- Type:
integer
- path: #/definitions/Endereco/properties/id
- logradouro
required
- Campo logradouro
- Type:
string
- path: #/definitions/Endereco/properties/logradouro
- numero
required
- Campo número
- Type:
string
- path: #/definitions/Endereco/properties/numero
- bairro
- Entidade entitulada Movimentacao
- Type:
object
- path: #/definitions/Movimentacao
- Properties
- dataMovimento
- Campo referente data de criação
- Type:
string
- path: #/definitions/Movimentacao/properties/dataMovimento
- String format must be a "date-time"
- descricao
- Campo referente descrição
- Type:
string
- path: #/definitions/Movimentacao/properties/descricao
- id
- Campo referente ID
- Type:
integer
- path: #/definitions/Movimentacao/properties/id
- numeroContaCredito
- Campo referente número da Conta Crédito
- Type:
integer
- path: #/definitions/Movimentacao/properties/numeroContaCredito
- numeroContaDebito
- Campo referente número da Conta Debito
- Type:
integer
- path: #/definitions/Movimentacao/properties/numeroContaDebito
- valor
- Campo referente valor
- Type:
number
- path: #/definitions/Movimentacao/properties/valor
- dataMovimento
HTTP METHOD | ENDPOINT | NO PARAMETERS & BODY | FUNÇÃO |
---|---|---|---|
GET | /agencias | NÃO & NÃO | Listar todas Agencias retorno Response Body |
POST | /agencias | SIM & SIM | Gravar Agencia Response Body |
GET | /agencias/{id} | SIM & SIM | Buscar Agencia exclusiva por id de identificação (PATH) |
PUT | /agencias/{id} | SIM & SIM | Atualizar Agencia pelo id por id de identificação (PATH) |
DELETE | /agencias/{id} | SIM & NÃO | Deleta Agencia pelo id por id de identificação (PATH) |
GET | /contas | NÃO & NÃO | Listar todas Contas Response Body |
POST | /contas | SIM & SIM | Gravar Conta Response Body |
GET | /contas/{id} | SIM & SIM | Buscar Conta exclusiva por id de identificação (PATH) |
PUT | /contas/{id} | SIM & SIM | Atualizar Conta pelo id por id de identificação (PATH) |
DELETE | /contas/{id} | SIM & NÃO | Deleta Conta pelo id por id de identificação (PATH) |
GET | /correntistas | NÃO & NÃO | Listar todas Correntistas Response Body |
POST | /correntistas | SIM & SIM | Gravar Correntista Response Body |
GET | /correntistas/{id} | SIM & SIM | Buscar Correntista exclusiva por id de identificação (PATH) |
PUT | /correntistas/{id} | SIM & SIM | Atualizar Correntista pelo id por id de identificação (PATH) |
DELETE | /correntistas/{id} | SIM & NÃO | Deleta Correntista pelo id por id de identificação (PATH) |
GET | /correntistas/{id}/contatos | SIM & SIM | Buscar Contato de Correntista exclusivo por id de identificação (PATH) |
POST | /correntistas/{id}/contatos | SIM & SIM | Gravar Contato de Correntista exclusivo por id de identificação (PATH) |
DELETE | /correntistas/{id}/contatos/{contatoId} | SIM & NÃO | Deleta Contato de Correntista exclusivo por id de identificação (PATH) |
GET | /correntistas/{id}/enderecos | SIM & SIM | Buscar Endereços de Correntista exclusivo por id de identificação (PATH) |
POST | /correntistas/{id}/enderecos | SIM & SIM | Gravar Endereço de Correntista exclusivo por id de identificação (PATH) |
DELETE | /correntistas/{id}/enderecos/{enderecoId} | SIM & NÃO | Deleta Endereço de Correntista exclusivo por id de identificação (PATH) |
GET | /movimentacoes | NÃO & NÃO | Listar todas Movimentações retorno no Response Body |
POST | /movimentacoes | SIM & SIM | Gravar Movimentações retorno no Response Body |
GET | /movimentacoes/{id} | SIM & SIM | Buscar Movimentação exclusiva por id de identificação (PATH) |
PUT | /movimentacoes/{id} | SIM & SIM | Atualizar Movimentação pelo id por id de identificação (PATH) |
DELETE | /movimentacoes/{id} | SIM & NÃO | Deleta Movimentação pelo id por id de identificação (PATH) |
1. Agencia
- Listar todas Agencias
- Gravar Agencia
- Buscar Agencia exclusiva por id de identificação
- Atualizar Agencia pelo id
- Deleta Agencia pelo id
2. Conta
- Listar todas Contas
- Gravar Conta
- Buscar Conta exclusiva por id de identificação
- Atualizar Conta pelo id
- Deleta Conta pelo id
3. Correntista
- Listar todas Correntistas
- Gravar Correntista
- Buscar Correntista exclusiva por id de identificação
- Atualizar Correntista pelo id
- Deleta Correntista pelo id
- Buscar Contato de Correntista exclusivo por id de identificação
- Gravar Contato de Correntista pelo id
- Deleta Contato de Correntista pelo id
- Buscar Endereço de Correntista exclusiva por id de identificação
- Gravar Endereço de Correntista pelo id
4. Movimentacao
- Listar todas Movimentacao
- Gravar Movimentacao
- Buscar Movimentacao exclusiva por id de identificação
- Atualizar Movimentacao pelo id
- Deleta Movimentacao pelo i a lista de agencias
CLIQUE PARA SER REDIRENCIONADO!
Obter acesso cuja API externa de Segurança cuja estratégia aplicada foi para separar as responsabilidades, assim segue a imagem:
Com a autorização realizada cujo Token, o sistema permite realizar algumas operações:
{ "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9. eyJleHAiOjE2MzkyMTMxOTIsInVzZXJfbmFtZSI6IjE4IiwiYXV0aG9yaXRpZXMiOlsiQURNSU4iXSwianRpIjoiMDg5MDg3ODAtMTAxNi00ZWU5LTk1MmMtYWI2NjA5ODk5OWMzIiwiY2xpZW50X2lkIjoiYmx1ZWJhbmstYXBwIiwic2NvcGUiOlsiUkVBRCIsIldSSVRFIl19. c6z4aMdNWMhcu5wRoFrTJ87Ur5M3uSF5c-RlMKsML32uWVeVGa0WAu-G4siyvwp7NufVwSf90tbA83mGQmLtc_Pig8vxpAwhIb1QRriFiQ_d0ZrljpnudSQAiyT4rgLn77jwvKwb1Yfu1j4E1BonsrSUINp2S6a2Uu3nzABVJ18DAaSaFupNGjtPylNPD5ZspNz0fnqsq2WXzKpbNnSv8gWiuvu1Tyx1nwoTg3KQJtUMFClJjQ5j_-G5s7Te02nVbtn_QaZ-aJcj4FntGNMkVwVWejgOARSCyhgkKT4mPn2IifNOkEzlnFLbOq9O59NKUntkex-aMB5hVX2YqOTqeA",
"token_type": "bearer", "expires_in": 43199, "scope": "READ WRITE", "jti": "08908780-1016-4ee9-952c-ab66098999c3" }
Retorno:
Por meio da Conta n° 18, cujo acesso seria ao funcionário, logo se pode realizar algumas requisições, por exemplo buscar todos Correntistas na Base de Dados. Conforme a imagem abaixo, a API contém a Estratégia de Paginação, já que tal tecnica melhora a performace! Assim, a medida que a há aumento de dados, a API contém a responsabilidade para tratar tais dados, e não ficando a incumbência APENAS Squad do Front.
Retorno:
Por meio da Conta n° 18, pode-se atualizar Correntista
Por meio da Conta n° 18, pode-se excluir Correntista, mas antes busque um Correntista especifico pelo ID, no caso ID = 2
Por meio da Conta n° 18, pode-se excluir Correntista, agora basta excluir! OBSERVAÇÃO: AO TENTAR EXCLUIR O USÁRIO DO ID = 2, ERRONIAMENTE FOI INSERIDO NO PARAM O ID = 5, O QUAL É ESSE QUE FAZ TODAS OPERAÇÕES DA API! DEVIDO ESSA PASSAGEM EQUIVOCADA, FOI OPORTUNO PARA DEMONSTRAR A FUNCIONALIDADE DO TRATAMENTO DE ERRO, VEJA A IMAGEM:
{ "status": 409, "timestamp": "2021-12-11T23:35:22.3690515Z", "type": "https://bluebank.6devs.com.br/entidade-em-uso", "title": "Entidade em uso", "detail": "Correntista de id 5 não pode ser removido, pois está em uso", "userMessage": "Correntista de id 5 não pode ser removido, pois está em uso" }
FEITO A OBSERVAÇÃO, VOLTA-SE À EXCLUSÃO DO ID = 2, VEJA A IMAGEM:
REGRA DE NEGOCIO:
Conforme o modelo é o Correntista com ID = 5, então, segue-se com esse para exeplicar o Fluxo de Movimentação cuja Entidade pode-se ser melhor compreendida pela a imagem abaixo:
Retorno:
Por motivo de custos, nessa API foi aplicado SNS como SANDBOX para envio de SMS, portanto só aceita números registrados e verificados, entretanto, o fluxo de envio de emails funciona para todos os destinatários
// index.js - triggered by an endpoint api gateway // publish a message containing the phone and message in the push SNS// Load the AWS SDK for Node.js const AWS = require('aws-sdk'); // Set region AWS.config.update({region: 'us-east-2'});
exports.handler = function(event, context, callback) {
// Create publish parameters var params = Message: event.message, /* required */ TopicArn: 'arn:aws:sns:xxxxxxxxxxxxxxxxxxxxxx:bluebankPushNotification' };
// Create promise and SNS service object var publishTextPromise = new AWS.SNS({apiVersion: '2010-03-31'}).publish(params).promise();
// Handle promise's fulfilled/rejected states
publishTextPromise.then(
function(data) {
console.log(Message ${params.Message} sent to the topic ${params.TopicArn}
);
console.log("MessageID is " + data.MessageId);
}).catch(
function(err) {
console.error(err, err.stack);
});
//callback(null,null);
const response = { statusCode: 200, body: JSON.stringify({ message: 'The request was fulfilled' }) }
return callback(null,response);
};
// arquivo index.js - disparado por um SNS de push // registra log no cloudwatch e dispara uma mensagem sms const aws = require("aws-sdk"); const sns = new aws.SNS({ region:'us-east-2' }); exports.handler = function(event, context, callback) { console.log("AWS lambda and SNS trigger "); console.log(event); const snsmessage = event.Records[0].Sns.Message; const tmp=snsmessage.substring(1); const message=tmp.substring(tmp.indexOf("]")+1); const telefone=tmp.substring(0,tmp.indexOf("]"));
console.log(snsmessage); console.log(message); console.log(telefone); sns.publish({ Message: message, PhoneNumber: telefone }, function (err, data) { if (err) { console.log(err); callback(err, null); } else { console.log(data); callback(null, data); } }); };
Agradecemos pela oportunidade!