Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Antonio Rueda
/
UJACoin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0f58d14c
authored
Dec 15, 2020
by
Antonio Rueda
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Definición de DTOs para servicios RESTful
parent
6c907007
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
309 additions
and
0 deletions
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOCliente.java
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOCuenta.java
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOMovimiento.java
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOTarjeta.java
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOCliente.java
0 → 100644
View file @
0f58d14c
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
es
.
ujaen
.
dae
.
ujacoin
.
controladoresREST
.
DTO
;
import
es.ujaen.dae.ujacoin.entidades.Cliente
;
import
java.time.LocalDate
;
/**
* DTO para recopilación de datos de cliente
* @author ajrueda
*/
public
class
DTOCliente
{
/** DNI del cliente*/
String
dni
;
/** Nombre completo */
String
nombre
;
/** Fecha de nacimiento */
LocalDate
fNacimiento
;
/** Dirección del domicilio */
String
direccion
;
/** Teléfono */
String
tlf
;
/** Email */
String
email
;
/** Clave de acceso al sistema */
String
clave
;
public
DTOCliente
(
String
dni
,
String
nombre
,
LocalDate
fNacimiento
,
String
direccion
,
String
tlf
,
String
email
,
String
clave
)
{
this
.
dni
=
dni
;
this
.
nombre
=
nombre
;
this
.
fNacimiento
=
fNacimiento
;
this
.
direccion
=
direccion
;
this
.
tlf
=
tlf
;
this
.
email
=
email
;
this
.
clave
=
clave
;
}
public
DTOCliente
(
Cliente
cliente
)
{
this
.
dni
=
cliente
.
getDni
();
this
.
nombre
=
cliente
.
getNombre
();
this
.
fNacimiento
=
cliente
.
getfNacimiento
();
this
.
direccion
=
cliente
.
getDireccion
();
this
.
tlf
=
cliente
.
getTlf
();
this
.
email
=
cliente
.
getEmail
();
this
.
clave
=
""
;
}
public
String
getDni
()
{
return
dni
;
}
public
String
getNombre
()
{
return
nombre
;
}
public
LocalDate
getfNacimiento
()
{
return
fNacimiento
;
}
public
String
getDireccion
()
{
return
direccion
;
}
public
String
getTlf
()
{
return
tlf
;
}
public
String
getEmail
()
{
return
email
;
}
public
String
getClave
()
{
return
clave
;
}
public
Cliente
aCliente
()
{
return
new
Cliente
(
dni
,
nombre
,
fNacimiento
,
direccion
,
tlf
,
email
,
clave
);
}
}
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOCuenta.java
0 → 100644
View file @
0f58d14c
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
es
.
ujaen
.
dae
.
ujacoin
.
controladoresREST
.
DTO
;
import
es.ujaen.dae.ujacoin.entidades.Cuenta
;
/**
* DTO para información de cuentas bancarias en UJACoin
* @author ajrueda
*/
public
class
DTOCuenta
{
/** Número de cuenta */
String
num
;
/** Saldo de la cuenta en Ujacoins */
float
saldo
;
/** Titular de la cuenta */
String
titular
;
public
DTOCuenta
(
String
num
,
float
saldo
,
String
titular
)
{
this
.
num
=
num
;
this
.
saldo
=
saldo
;
this
.
titular
=
titular
;
}
public
DTOCuenta
(
Cuenta
cuenta
)
{
this
.
num
=
cuenta
.
getNum
();
this
.
saldo
=
cuenta
.
getSaldo
();
this
.
titular
=
cuenta
.
getTitular
().
getDni
();
}
public
String
getNum
()
{
return
num
;
}
public
float
getSaldo
()
{
return
saldo
;
}
public
String
getTitular
()
{
return
titular
;
}
}
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOMovimiento.java
0 → 100644
View file @
0f58d14c
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
es
.
ujaen
.
dae
.
ujacoin
.
controladoresREST
.
DTO
;
import
es.ujaen.dae.ujacoin.entidades.Cuenta
;
import
es.ujaen.dae.ujacoin.entidades.Tarjeta
;
import
es.ujaen.dae.ujacoin.entidades.movimientos.Ingreso
;
import
es.ujaen.dae.ujacoin.entidades.movimientos.Movimiento
;
import
es.ujaen.dae.ujacoin.entidades.movimientos.Reintegro
;
import
es.ujaen.dae.ujacoin.entidades.movimientos.TransferenciaEmitida
;
import
es.ujaen.dae.ujacoin.entidades.movimientos.TransferenciaRecibida
;
import
java.util.List
;
import
java.util.Optional
;
/**
*
* @author ajrueda
*/
public
class
DTOMovimiento
{
static
final
String
ETIQ_INGRESO
=
"ingreso"
;
static
final
String
ETIQ_REINTEGRO
=
"reintegro"
;
static
final
String
ETIQ_TRANSFERENCIA_EMITIDA
=
"transferenciaEmitida"
;
static
final
String
ETIQ_TRANSFERENCIA_RECIBIDA
=
"transferenciaRecibida"
;
/** Tipo del movimiento: ingreso, reintegro, transferencia */
String
tipo
;
/** Número de tarjeta para ingreso/reintegro */
String
numTarjeta
;
/** Cuenta destino para transferencia */
String
numCuenta
;
/** Importe de la operación */
float
importe
;
public
DTOMovimiento
(
String
tipo
,
String
numTarjeta
,
String
numCuenta
,
int
importe
)
{
this
.
tipo
=
tipo
;
this
.
numTarjeta
=
numTarjeta
;
this
.
numCuenta
=
numCuenta
;
this
.
importe
=
importe
;
}
public
DTOMovimiento
(
Movimiento
movimiento
)
{
this
.
importe
=
movimiento
.
getImporte
();
if
(
movimiento
instanceof
Ingreso
)
{
this
.
tipo
=
ETIQ_INGRESO
;
this
.
numTarjeta
=
((
Ingreso
)
movimiento
).
getTarjeta
().
getNum
();
}
else
if
(
movimiento
instanceof
Reintegro
)
{
this
.
tipo
=
ETIQ_REINTEGRO
;
this
.
numTarjeta
=
((
Reintegro
)
movimiento
).
getTarjeta
().
getNum
();
}
else
if
(
movimiento
instanceof
TransferenciaEmitida
)
{
this
.
tipo
=
ETIQ_TRANSFERENCIA_EMITIDA
;
this
.
numCuenta
=
((
TransferenciaEmitida
)
movimiento
).
getCuentaDestino
().
getNum
();
}
else
if
(
movimiento
instanceof
TransferenciaRecibida
)
{
this
.
tipo
=
ETIQ_TRANSFERENCIA_RECIBIDA
;
this
.
numCuenta
=
((
TransferenciaRecibida
)
movimiento
).
getCuentaOrigen
().
getNum
();
}
}
public
String
getTipo
()
{
return
tipo
;
}
public
String
getNumTarjeta
()
{
return
numTarjeta
;
}
public
String
getNumCuenta
()
{
return
numCuenta
;
}
public
float
getImporte
()
{
return
importe
;
}
public
Optional
<
Movimiento
>
aMovimiento
(
List
<
Tarjeta
>
tarjetas
,
List
<
Cuenta
>
cuentas
)
{
if
(
tipo
==
null
)
{
return
Optional
.
empty
();
}
switch
(
tipo
.
toLowerCase
())
{
case
ETIQ_INGRESO:
if
(
numTarjeta
==
null
)
{
return
Optional
.
empty
();
}
return
tarjetas
.
stream
()
.
filter
(
t
->
t
.
getNum
().
equals
(
numTarjeta
))
.
findAny
()
.
map
(
t
->
new
Ingreso
(
t
,
importe
));
case
ETIQ_REINTEGRO:
if
(
numTarjeta
==
null
)
{
return
Optional
.
empty
();
}
return
tarjetas
.
stream
()
.
filter
(
t
->
t
.
getNum
().
equals
(
numTarjeta
))
.
findAny
()
.
map
(
t
->
new
Reintegro
(
t
,
importe
));
case
ETIQ_TRANSFERENCIA_EMITIDA:
if
(
numCuenta
==
null
)
{
return
Optional
.
empty
();
}
return
cuentas
.
stream
()
.
filter
(
c
->
c
.
getNum
().
equals
(
numCuenta
))
.
findAny
()
.
map
(
c
->
new
TransferenciaEmitida
(
c
,
importe
));
default
:
return
Optional
.
empty
();
}
}
}
src/main/java/es/ujaen/dae/ujacoin/controladoresREST/DTO/DTOTarjeta.java
0 → 100644
View file @
0f58d14c
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
es
.
ujaen
.
dae
.
ujacoin
.
controladoresREST
.
DTO
;
import
es.ujaen.dae.ujacoin.entidades.Tarjeta
;
import
java.time.LocalDate
;
/**
* DTO para información de tarjetas bancarias
* @author ajrueda
*/
public
class
DTOTarjeta
{
/** Número de tarjeta */
String
num
;
/** Titular de la tarjeta (puede ser diferente al cliente que la usa */
String
titular
;
/** Fecha de caducidad */
LocalDate
fechaCaducidad
;
/** Código de seguridad (CVC) */
String
cvc
;
public
DTOTarjeta
(
String
num
,
String
titular
,
LocalDate
fechaCaducidad
,
String
cvc
)
{
this
.
num
=
num
;
this
.
titular
=
titular
;
this
.
fechaCaducidad
=
fechaCaducidad
;
this
.
cvc
=
cvc
;
}
public
DTOTarjeta
(
Tarjeta
tarjeta
)
{
this
.
num
=
tarjeta
.
getNum
();
this
.
titular
=
tarjeta
.
getTitular
();
this
.
fechaCaducidad
=
tarjeta
.
getFechaCaducidad
();
this
.
cvc
=
tarjeta
.
getCvc
();
}
public
String
getNum
()
{
return
num
;
}
public
String
getTitular
()
{
return
titular
;
}
public
LocalDate
getFechaCaducidad
()
{
return
fechaCaducidad
;
}
public
String
getCvc
()
{
return
cvc
;
}
public
Tarjeta
aTarjeta
()
{
return
new
Tarjeta
(
num
,
titular
,
fechaCaducidad
,
cvc
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment