Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rubén Ramírez
/
MangAffinity
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
67990eb3
authored
Apr 07, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [Mapper]: Métodos creados para pasar a entity o dto para las reseñas
parent
f558a4a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
4 deletions
src/main/java/com/ujaen/tfg/mangaffinity/rest/DTO/Mapper.java
src/main/java/com/ujaen/tfg/mangaffinity/rest/DTO/Mapper.java
View file @
67990eb3
package
com
.
ujaen
.
tfg
.
mangaffinity
.
rest
.
DTO
;
import
com.ujaen.tfg.mangaffinity.entidades.Capitulo
;
import
com.ujaen.tfg.mangaffinity.entidades.FuenteCapitulo
;
import
com.ujaen.tfg.mangaffinity.entidades.Recurso
;
import
com.ujaen.tfg.mangaffinity.entidades.Usuario
;
import
com.ujaen.tfg.mangaffinity.entidades.*
;
import
com.ujaen.tfg.mangaffinity.excepciones.RecursoNoExiste
;
import
com.ujaen.tfg.mangaffinity.excepciones.UsuarioNoExiste
;
import
com.ujaen.tfg.mangaffinity.repositorios.RepositorioCapitulo
;
import
com.ujaen.tfg.mangaffinity.repositorios.RepositorioUsuario
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Base64
;
...
...
@@ -105,4 +106,27 @@ public class Mapper {
public
List
<
DTOCapitulo
>
dtoLista
(
List
<
Capitulo
>
capitulos
)
{
return
capitulos
.
stream
().
map
(
this
::
dto
).
collect
(
Collectors
.
toList
());
}
public
Resena
entity
(
DTOResena
dtoResena
,
Usuario
usuario
,
Recurso
recurso
)
{
return
new
Resena
(
usuario
,
recurso
,
dtoResena
.
getEstrellas
(),
dtoResena
.
getTexto
());
}
// En la clase Mapper
public
DTOResena
dto
(
Resena
resena
)
{
DTOResena
dto
=
new
DTOResena
();
dto
.
setUsuarioId
(
resena
.
getUsuario
().
getId
());
dto
.
setUsuarioNombre
(
resena
.
getUsuario
().
getNombreUsuario
());
dto
.
setRecursoId
(
resena
.
getRecurso
().
getId
());
dto
.
setEstrellas
(
resena
.
getEstrellas
());
dto
.
setTexto
(
resena
.
getTexto
());
dto
.
setFechaPublicacion
(
resena
.
getFechaPublicacion
());
return
dto
;
}
public
List
<
DTOResena
>
dtoListaResenas
(
List
<
Resena
>
resenas
)
{
return
resenas
.
stream
()
.
map
(
this
::
dto
)
.
collect
(
Collectors
.
toList
());
}
}
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