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
503f16aa
authored
Mar 28, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix: [BibliotecaPersonalController]: Pequeño cambio en la estructuración del código
parent
7d0a7880
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
src/main/java/com/ujaen/tfg/mangaffinity/rest/BibliotecaPersonalController.java
src/main/java/com/ujaen/tfg/mangaffinity/rest/BibliotecaPersonalController.java
View file @
503f16aa
...
...
@@ -32,6 +32,7 @@ public class BibliotecaPersonalController {
/**
* Añade un recurso a la biblioteca personal del usuario.
*
* Devuelve:
* - 201 CREATED si se agrega correctamente.
* - 404 NOT FOUND si la biblioteca o el recurso no existen.
...
...
@@ -68,9 +69,9 @@ public class BibliotecaPersonalController {
/**
* Lista los recursos de una biblioteca por categoría.
*
* Devuelve:
* - 200 OK con la lista de recursos si existen.
* - 204 NO CONTENT si no hay recursos en la categoría.
* - 200 OK con la lista de recursos (vacía o no).
* - 400 BAD REQUEST si la categoría es inválida.
* - 404 NOT FOUND si la biblioteca no existe.
* - 500 INTERNAL SERVER ERROR en caso de error inesperado.
...
...
@@ -79,9 +80,7 @@ public class BibliotecaPersonalController {
public
ResponseEntity
<
List
<
DTORecursoEnBiblioteca
>>
listarRecursosPorCategoria
(
@PathVariable
Long
usuarioId
,
@PathVariable
String
categoria
)
{
try
{
BibliotecaPersonal
biblioteca
=
servicioUsuarios
.
obtenerBibliotecaDeUsuario
(
usuarioId
);
if
(
biblioteca
==
null
)
return
ResponseEntity
.
status
(
HttpStatus
.
NOT_FOUND
).
build
();
Categoria
categoriaEnum
;
...
...
@@ -91,9 +90,8 @@ public class BibliotecaPersonalController {
return
ResponseEntity
.
status
(
HttpStatus
.
BAD_REQUEST
).
build
();
}
List
<
BibliotecaPersonalRecurso
>
recursos
=
servicioBibliotecaPersonal
.
listarPorCategoria
(
biblioteca
.
getId
(),
categoriaEnum
);
if
(
recursos
.
isEmpty
())
return
ResponseEntity
.
status
(
HttpStatus
.
NO_CONTENT
).
build
();
List
<
BibliotecaPersonalRecurso
>
recursos
=
servicioBibliotecaPersonal
.
listarPorCategoria
(
biblioteca
.
getId
(),
categoriaEnum
);
List
<
DTORecursoEnBiblioteca
>
dtoRecursos
=
recursos
.
stream
()
.
map
(
bpr
->
new
DTORecursoEnBiblioteca
(
...
...
@@ -105,6 +103,7 @@ public class BibliotecaPersonalController {
:
null
))
.
collect
(
Collectors
.
toList
());
return
ResponseEntity
.
ok
(
dtoRecursos
);
}
catch
(
Exception
e
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
...
...
@@ -114,6 +113,7 @@ public class BibliotecaPersonalController {
/**
* Elimina un recurso de la biblioteca personal del usuario.
* Devuelve:
*
* - 204 NO CONTENT si se elimina correctamente.
* - 404 NOT FOUND si la biblioteca o el recurso no existen.
* - 500 INTERNAL SERVER ERROR en caso de error inesperado.
...
...
@@ -138,6 +138,7 @@ public class BibliotecaPersonalController {
/**
* Obtiene un recurso de la biblioteca personal del usuario.
*
* Devuelve:
* - 200 OK con el recurso si existe.
* - 204 NO CONTENT si el recurso no está en la biblioteca.
...
...
@@ -172,6 +173,7 @@ public class BibliotecaPersonalController {
/**
* Cambia la categoría de un recurso en la biblioteca personal del usuario.
*
* Devuelve:
* - 200 OK si se cambia correctamente.
* - 400 BAD REQUEST si la categoría es nula.
...
...
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