-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserController.java
More file actions
49 lines (42 loc) · 1.8 KB
/
UserController.java
File metadata and controls
49 lines (42 loc) · 1.8 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.podzilla.auth.controller;
import com.podzilla.auth.dto.UpdateRequest;
import com.podzilla.auth.dto.UserDetailsRequest;
import com.podzilla.auth.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
@RestController
@RequestMapping("/user")
public class UserController {
private static final Logger LOGGER =
LoggerFactory.getLogger(UserController.class);
private final UserService userService;
public UserController(final UserService userService) {
this.userService = userService;
}
@PutMapping("/update")
@Operation(summary = "Update user name",
description = "Allows user to update their name.")
@ApiResponse(responseCode = "200",
description = "User profile updated successfully")
public void updateProfile(@RequestBody final UpdateRequest
updateRequest) {
LOGGER.debug("Received updateProfile request");
userService.updateUserProfile(updateRequest);
}
@GetMapping("/details")
@Operation(summary = "Get user details",
description = "Fetches the details of the current user.")
@ApiResponse(responseCode = "200",
description = "User details fetched successfully")
public UserDetailsRequest getUserDetails() {
LOGGER.debug("Received getUserDetails request");
return userService.getUserDetails();
}
}