package com.diluv.api.controller;

import com.diluv.api.mapping.JsonGetRequestMapping;
import com.diluv.api.response.Response;
import com.diluv.api.response.model.ModelGame;
import com.diluv.api.service.games.GameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1/games")
public class GamesController {

    @Autowired
    private GameService gameService;

    @Transactional
    @JsonGetRequestMapping(value = {"", "/"})
    public Response getGames() {
        final List<ModelGame> games = this.gameService.getList();
        return new Response(games);
    }
}
