Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
AppRecetas
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
3f85146c
authored
Jun 20, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
perf(user): cambio readById por readMe para leer información propia
parent
6b7e0d57
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
src/main/java/com/example/apprecetas/user/infrastructure/controller/ReadUserController.java
src/main/java/com/example/apprecetas/user/infrastructure/controller/ReadUserController.java
View file @
3f85146c
package
com
.
example
.
apprecetas
.
user
.
infrastructure
.
controller
;
import
com.example.apprecetas.user.application.ReadUserUseCase
;
import
com.example.apprecetas.user.domain.entity.User
;
import
com.example.apprecetas.user.infrastructure.controller.dto.UserOutputDto
;
import
com.example.apprecetas.user.infrastructure.mapper.UserMapper
;
import
lombok.RequiredArgsConstructor
;
import
org.mapstruct.factory.Mappers
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -22,9 +23,11 @@ public class ReadUserController {
private
final
UserMapper
mapper
=
Mappers
.
getMapper
(
UserMapper
.
class
);
@GetMapping
(
"/id/{id}"
)
public
ResponseEntity
<
UserOutputDto
>
readById
(
@PathVariable
String
id
)
{
return
ResponseEntity
.
ok
().
body
(
mapper
.
map
(
service
.
readById
(
id
)));
@GetMapping
(
"/me"
)
public
ResponseEntity
<
UserOutputDto
>
readMe
()
{
String
email
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
();
User
user
=
service
.
readByEmail
(
email
);
return
ResponseEntity
.
ok
().
body
(
mapper
.
map
(
service
.
readById
(
user
.
getId
())));
}
@GetMapping
...
...
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