package de.szut.casino.user;

import de.szut.casino.user.dto.GetUserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/users")
public class UserController {

    private final UserService userService;

    private final UserMappingService userMappingService;

    public UserController(UserService userService, UserMappingService userMappingService) {
        this.userService = userService;
        this.userMappingService = userMappingService;
    }

    @GetMapping("/me")
    public ResponseEntity<GetUserDto> getCurrentUser() {
        return ResponseEntity.ok(userMappingService.mapToGetUserDto(userService.getCurrentUser()));
    }
}
