Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alvaro Ordóñez Romero
/
DAE-aha00026-aor00039
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
2e093206
authored
Dec 09, 2023
by
Alvaro Ordóñez Romero
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Adición de DTOReserva, DTOSolicitud, DTOViaje, realizado junto con Álvaro Herrera
parent
dd3f1821
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
src/main/java/com/carpooling/carpoolingaoraha/rest/dto/DTOSolicitud.java
src/main/java/com/carpooling/carpoolingaoraha/rest/dto/DTOViaje.java
src/main/java/com/carpooling/carpoolingaoraha/rest/dto/DTOSolicitud.java
0 → 100644
View file @
2e093206
package
com
.
carpooling
.
carpoolingaoraha
.
rest
.
dto
;
import
com.carpooling.carpoolingaoraha.entidades.Reserva
;
import
com.carpooling.carpoolingaoraha.entidades.Solicitud
;
import
com.carpooling.carpoolingaoraha.entidades.Usuario
;
import
java.util.Objects
;
public
record
DTOSolicitud
(
Long
id
,
Reserva
res
,
Usuario
usuario
){
public
DTOSolicitud
(
Solicitud
sol
){
this
(
sol
.
getId
(),
sol
.
getReserva
(),
sol
.
getPasajero
());
}
public
Solicitud
altaSolicitud
(){
return
new
Solicitud
(
res
,
usuario
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
DTOSolicitud
that
=
(
DTOSolicitud
)
o
;
return
Objects
.
equals
(
id
,
that
.
id
)
&&
Objects
.
equals
(
res
,
that
.
res
)
&&
Objects
.
equals
(
usuario
,
that
.
usuario
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
,
res
,
usuario
);
}
@Override
public
String
toString
()
{
return
"DTOSolicitud{"
+
"id="
+
id
+
", res="
+
res
+
", usuario="
+
usuario
+
'}'
;
}
}
src/main/java/com/carpooling/carpoolingaoraha/rest/dto/DTOViaje.java
0 → 100644
View file @
2e093206
package
com
.
carpooling
.
carpoolingaoraha
.
rest
.
dto
;
import
java.util.Date
;
import
java.util.Objects
;
import
com.carpooling.carpoolingaoraha.entidades.SistemaCarPooling
;
import
com.carpooling.carpoolingaoraha.entidades.Viaje
;
public
record
DTOViaje
(
String
origen
,
String
destino
,
Date
fechaSalida
,
int
nAsientos
,
int
precioAsiento
,
int
idViaje
)
{
public
DTOViaje
(
Viaje
v
){
this
(
v
.
getOrigen
(),
v
.
getDestino
(),
v
.
getFechaSalida
(),
v
.
getnAsientos
(),
v
.
getPrecioAsiento
(),
v
.
getIdViaje
());
}
public
Viaje
altaViaje
(
SistemaCarPooling
sistemaCarPooling
){
return
new
Viaje
(
origen
,
destino
,
fechaSalida
,
nAsientos
,
precioAsiento
,
idViaje
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
DTOViaje
dtoViaje
=
(
DTOViaje
)
o
;
return
nAsientos
==
dtoViaje
.
nAsientos
&&
precioAsiento
==
dtoViaje
.
precioAsiento
&&
idViaje
==
dtoViaje
.
idViaje
&&
Objects
.
equals
(
origen
,
dtoViaje
.
origen
)
&&
Objects
.
equals
(
destino
,
dtoViaje
.
destino
)
&&
Objects
.
equals
(
fechaSalida
,
dtoViaje
.
fechaSalida
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
origen
,
destino
,
fechaSalida
,
nAsientos
,
precioAsiento
,
idViaje
);
}
@Override
public
String
toString
()
{
return
"DTOViaje{"
+
"origen='"
+
origen
+
'\''
+
", destino='"
+
destino
+
'\''
+
", fechaSalida="
+
fechaSalida
+
", nAsientos="
+
nAsientos
+
", precioAsiento="
+
precioAsiento
+
", idViaje="
+
idViaje
+
'}'
;
}
}
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