package ru.kayashov.bar.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ru.kayashov.bar.controller.dto.VisitorResponseDto;
import ru.kayashov.bar.repository.VisitorsRepository;
import ru.kayashov.bar.service.VisitorService;

import java.util.List;
import java.util.stream.Stream;

@Slf4j
@CrossOrigin(origins = {"*"})
@RestController
@RequestMapping("/api/visitors")
@RequiredArgsConstructor
public class VisitorController {

    private final VisitorService visitorService;

    @GetMapping
    public List<VisitorResponseDto> getVisitors() {
        return visitorService.findAll();
    }

    @PostMapping("/invite")
    public void invite(@RequestParam Boolean value, @RequestParam Long id) {
        visitorService.invited(value, id);
    }
}
