TDMS/server/src/main/java/ru/tubryansk/tdms/controller/UserController.java
Maksim Skobaro c2d19a7724 improved, more featured, fixed
Exceptions and Errors are better
Files structure is better
New ComponentContext.ts
New DataTable.tsx tables.ts
Massive components refactoring
New Group.java
New LoggingRequestFilter.java LoggingSessionListener.java
New NotificationStore.ts SysInfoStore.ts
New reactiveValue.ts ReactiveControls.tsx
New dependencies
And much more
2025-02-07 07:05:15 +03:00

52 lines
1.5 KiB
Java

package ru.tubryansk.tdms.controller;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ru.tubryansk.tdms.controller.payload.LoginDTO;
import ru.tubryansk.tdms.controller.payload.RegistrationDTO;
import ru.tubryansk.tdms.controller.payload.UserDTO;
import ru.tubryansk.tdms.service.AuthenticationService;
import ru.tubryansk.tdms.service.CallerService;
import ru.tubryansk.tdms.service.UserService;
import java.util.List;
@RestController
@RequestMapping("/api/v1/user")
@Slf4j
public class UserController {
@Autowired
private AuthenticationService authenticationService;
@Autowired
private CallerService callerService;
@Autowired
private UserService userService;
@GetMapping("/current")
public UserDTO getCurrentUser() {
return callerService.getCallerUserDTO();
}
@PostMapping("/logout")
public void logout() {
authenticationService.logout();
}
@PostMapping("/login")
public void login(@RequestBody @Valid LoginDTO loginDTO) {
authenticationService.login(loginDTO.getUsername(), loginDTO.getPassword());
}
@PostMapping("/register")
public void post(@RequestBody @Valid RegistrationDTO registrationDTO) {
userService.registerUser(registrationDTO);
}
@GetMapping("/get-all")
public List<UserDTO> getAllUsers() {
return userService.getAllUsers();
}
}