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
07b3f3a3
authored
Apr 20, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [ServicioBibliotecaPersonal]: Añadidas las funciones para la gestión de favoritos
parent
91dfaec9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
src/main/java/com/ujaen/tfg/mangaffinity/servicios/ServicioBibliotecaPersonal.java
src/main/java/com/ujaen/tfg/mangaffinity/servicios/ServicioBibliotecaPersonal.java
View file @
07b3f3a3
...
...
@@ -115,5 +115,35 @@ public class ServicioBibliotecaPersonal {
return
repositorioBibliotecaPersonalRecurso
.
buscarRecursoEnBiblioteca
(
bibliotecaPersonalId
,
recursoId
);
}
@Transactional
public
void
anadirFavorito
(
Long
bibliotecaPersonalId
,
Long
recursoId
)
{
BibliotecaPersonal
biblioteca
=
repositorioBibliotecaPersonalRecurso
.
obtenerBibliotecaPorId
(
bibliotecaPersonalId
)
.
orElseThrow
(
UsuarioSinBiblioteca:
:
new
);
Recurso
recurso
=
repositorioBibliotecaPersonalRecurso
.
obtenerRecursoPorId
(
recursoId
)
.
orElseThrow
(
RecursoNoExiste:
:
new
);
biblioteca
.
anadirFavorito
(
recurso
.
getId
());
}
@Transactional
public
void
eliminarFavorito
(
Long
bibliotecaPersonalId
,
Long
recursoId
)
{
BibliotecaPersonal
biblioteca
=
repositorioBibliotecaPersonalRecurso
.
obtenerBibliotecaPorId
(
bibliotecaPersonalId
)
.
orElseThrow
(
UsuarioSinBiblioteca:
:
new
);
biblioteca
.
eliminarFavorito
(
recursoId
);
}
@Transactional
(
readOnly
=
true
)
public
List
<
Long
>
obtenerFavoritos
(
Long
bibliotecaPersonalId
)
{
BibliotecaPersonal
biblioteca
=
repositorioBibliotecaPersonalRecurso
.
obtenerBibliotecaPorId
(
bibliotecaPersonalId
)
.
orElseThrow
(
UsuarioSinBiblioteca:
:
new
);
return
biblioteca
.
obtenerFavoritos
();
}
}
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