package ru.kayashov.bar.controller;

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.RestController;
import ru.kayashov.bar.model.entity.Category;

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

@Slf4j
@CrossOrigin(origins = {"*"})
@RestController
@RequestMapping("/api/category")
public class CategoryController {

    @PermitAll
    @GetMapping
    public List<String> getCategory() {
        return Arrays.stream(Category.values()).map(Category::getName).toList();
    }
}
