proj/Backend/src/main/java/de/itsolutions/ticketsystem/controller/UserController.java
2026-01-22 09:41:05 +01:00

35 lines
1.2 KiB
Java

package de.itsolutions.ticketsystem.controller;
import de.itsolutions.ticketsystem.dto.Dtos;
import de.itsolutions.ticketsystem.entity.User;
import de.itsolutions.ticketsystem.service.AuthService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
/**
* Controller for stuff that relates to the user, but not necessarily login/register.
* Kept separate because clean code or whatever.
*/
@RestController
@RequestMapping("/api/users")
public class UserController {
private final AuthService authService;
public UserController(AuthService authService) {
this.authService = authService;
}
/**
* Updates the theme for the current user.
* @param request The theme update request
* @param principal The security principal (the logged in dude)
* @return The updated user
*/
@PatchMapping("/theme")
public ResponseEntity<User> updateTheme(@RequestBody Dtos.ThemeUpdateRequest request, Principal principal) {
// Just delegating to service, standard procedure
return ResponseEntity.ok(authService.updateTheme(principal.getName(), request.getTheme()));
}
}