package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.request.BattleEventRequest;
import com.caliverse.admin.domain.response.BattleEventResponse;
import com.caliverse.admin.domain.service.BattleEventService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Tag(name = "게임", description = "게임 api")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/game")
public class GameController {
    private final BattleEventService battleEventService;
    @GetMapping("/setting/list")
    public ResponseEntity<BattleEventResponse> getGameSettingList(
            @RequestParam Map<String, String> requestParam){
        return ResponseEntity.ok().body( battleEventService.getBattleEventList(requestParam));
    }

    @GetMapping("/setting/detail/{id}")
    public ResponseEntity<BattleEventResponse> getGameSettingDetail(
            @PathVariable("id") Long id){
        return ResponseEntity.ok().body( battleEventService.getBattleEventDetail(id));
    }
    
    @PostMapping("/setting")
    public ResponseEntity<BattleEventResponse> postGameSetting(
            @RequestBody BattleEventRequest battleEventRequest){

        return ResponseEntity.ok().body(battleEventService.postBattleEvent(battleEventRequest));
    }

    @PutMapping("/setting/{id}")
    public ResponseEntity<BattleEventResponse> updateGameSetting(
            @PathVariable("id")Long id, @RequestBody BattleEventRequest battleEventRequest){

        return ResponseEntity.ok().body(battleEventService.updateBattleEvent(id, battleEventRequest));
    }

    @GetMapping("/match/list")
    public ResponseEntity<BattleEventResponse> getGameMatchList(
            @RequestParam Map<String, String> requestParam){
        return ResponseEntity.ok().body( battleEventService.getBattleEventList(requestParam));
    }

    @GetMapping("/match/detail/{id}")
    public ResponseEntity<BattleEventResponse> getGameMatchDetail(
            @PathVariable("id") Long id){
        return ResponseEntity.ok().body( battleEventService.getBattleEventDetail(id));
    }

    @PostMapping("/match")
    public ResponseEntity<BattleEventResponse> postGameMatch(
            @RequestBody BattleEventRequest battleEventRequest){

        return ResponseEntity.ok().body(battleEventService.postBattleEvent(battleEventRequest));
    }

    @PutMapping("/match/{id}")
    public ResponseEntity<BattleEventResponse> updateGameMatch(
            @PathVariable("id")Long id, @RequestBody BattleEventRequest battleEventRequest){

        return ResponseEntity.ok().body(battleEventService.updateBattleEvent(id, battleEventRequest));
    }
    
    @DeleteMapping("/match/delete")
    public ResponseEntity<BattleEventResponse> deleteGameMatch(
            @RequestBody BattleEventRequest battleEventRequest){

        return ResponseEntity.ok().body(battleEventService.deleteBattleEvent(battleEventRequest));
    }
}
