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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ru.kayashov.bar.controller.dto.cocktail.ReceiptResponseDto;
import ru.kayashov.bar.service.ReceiptService;

import javax.annotation.security.PermitAll;
import java.util.List;

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

    private final ReceiptService receiptService;

    @PermitAll
    @GetMapping
    public List<ReceiptResponseDto> getReceipt(@RequestParam("id") Long id) {
        return receiptService.getReceiptList(id);
    }
}
