-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttendeeController.java
More file actions
30 lines (26 loc) · 1.22 KB
/
AttendeeController.java
File metadata and controls
30 lines (26 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.meevent.webapi.Controller.v1;
import com.meevent.webapi.dto.request.UpdateAttendeeProfileRequest;
import com.meevent.webapi.dto.response.AttendeeProfileResponse;
import com.meevent.webapi.dto.response.MessageResponse;
import com.meevent.webapi.service.AttendeeService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/v1/attendees")
@RequiredArgsConstructor
public class AttendeeController {
private final AttendeeService attendeeService;
@PreAuthorize("isAuthenticated()")
@PatchMapping("/profile")
public ResponseEntity<MessageResponse> updateMyProfile(@Valid @RequestBody UpdateAttendeeProfileRequest request) {
String userEmail = SecurityContextHolder.getContext().getAuthentication().getName();
attendeeService.updateProfile(userEmail, request);
return ResponseEntity.ok(new MessageResponse("Perfil actualizado correctamente"));
}
}