package de.oaa.xxx.games.vanilla.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import de.oaa.xxx.games.common.aufgaben.DefaultFiller;

@RestController
@RequestMapping("/vanilla/filler")
public class VanillaFillerController {

    private static final Logger LOGGER = LoggerFactory.getLogger(VanillaFillerController.class);

    private final DefaultFiller defaultFiller;

    public VanillaFillerController(DefaultFiller defaultFiller) {
        this.defaultFiller = defaultFiller;
    }

    @PostMapping
    public ResponseEntity<Void> fill() {
        try {
            defaultFiller.fill();
            return ResponseEntity.ok().build();
        } catch (Exception exception) {
            LOGGER.error(exception.getMessage(), exception);
            return ResponseEntity.internalServerError().build();
        }
    }
}
