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
fc669a00
authored
Feb 23, 2025
by
Rubén Ramírez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat: [RecursosController]:Implementada la función de modificar recurso en el controlador
parent
e403fa55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
src/main/java/com/ujaen/tfg/mangaffinity/rest/RecursosController.java
src/main/java/com/ujaen/tfg/mangaffinity/seguridad/ServicioSeguridad.java
src/main/java/com/ujaen/tfg/mangaffinity/rest/RecursosController.java
View file @
fc669a00
...
...
@@ -121,6 +121,22 @@ public class RecursosController {
}
}
@PutMapping
(
"/{id}"
)
public
ResponseEntity
<
DTORecurso
>
modificarRecurso
(
@PathVariable
Long
id
,
@RequestBody
DTORecurso
dtoRecurso
)
{
try
{
Recurso
nuevosDatos
=
mapper
.
entity
(
dtoRecurso
);
Recurso
recursoModificado
=
servicioRecursos
.
modificarRecurso
(
id
,
nuevosDatos
);
return
ResponseEntity
.
ok
(
mapper
.
dto
(
recursoModificado
));
}
catch
(
RecursoNoExiste
e
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
NOT_FOUND
).
build
();
}
catch
(
SecurityException
e
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
UNAUTHORIZED
).
build
();
}
catch
(
Exception
e
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
}
}
...
...
src/main/java/com/ujaen/tfg/mangaffinity/seguridad/ServicioSeguridad.java
View file @
fc669a00
...
...
@@ -34,9 +34,11 @@ public class ServicioSeguridad {
.
requestMatchers
(
HttpMethod
.
GET
,
"/recursos/autor/**"
).
permitAll
()
.
requestMatchers
(
HttpMethod
.
GET
,
"/recursos/genero/**"
).
permitAll
()
.
requestMatchers
(
HttpMethod
.
GET
,
"/recursos/fecha"
).
permitAll
()
.
requestMatchers
(
HttpMethod
.
GET
,
"/recursos/{id}"
).
permitAll
()
// ✅ Nueva ruta para buscar por ID
.
requestMatchers
(
HttpMethod
.
GET
,
"/recursos/{id}"
).
permitAll
()
.
requestMatchers
(
HttpMethod
.
POST
,
"/recursos/"
).
hasAuthority
(
"ROLE_ADMIN"
)
.
requestMatchers
(
HttpMethod
.
DELETE
,
"/recursos/{id}"
).
hasAuthority
(
"ROLE_ADMIN"
)
// ✅ Solo admins pueden borrar
.
requestMatchers
(
HttpMethod
.
PUT
,
"/recursos/{id}"
).
hasAuthority
(
"ROLE_ADMIN"
)
.
requestMatchers
(
HttpMethod
.
DELETE
,
"/recursos/{id}"
).
hasAuthority
(
"ROLE_ADMIN"
)
.
anyRequest
().
authenticated
()
)
.
addFilterBefore
(
new
JwtFilter
(
jwtUtil
),
UsernamePasswordAuthenticationFilter
.
class
)
...
...
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