package es.uv.dagarcos.master.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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 es.uv.dagarcos.master.dto.MasterEventDto;
import es.uv.dagarcos.master.service.EventDashboardService;

@RestController
@RequestMapping("/master/events")
@CrossOrigin
public class DashboardEventController {

    @Autowired
    private EventDashboardService eventService;

    @GetMapping
    public Page<MasterEventDto> getEvents(@RequestParam(defaultValue = "") String shard, 
                                          @RequestParam(defaultValue = "") String player, 
                                          @RequestParam(defaultValue = "") String action, 
                                          Pageable pageable) {

        return eventService.getEvents(shard, player, action, pageable);
    }
}
