package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.response.DictionaryResponse;
import com.caliverse.admin.domain.service.MetaDataService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
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/dictionary")
public class DictionaryController {
    private final MetaDataService metaDataService;

    @GetMapping("/brand/list")
    public ResponseEntity<DictionaryResponse> brandList(){
        return ResponseEntity.ok().body( metaDataService.getBrandList());
    }

    @GetMapping("/ranking/list")
    public ResponseEntity<DictionaryResponse> rankingList(){
        return ResponseEntity.ok().body( metaDataService.getRankingList());
    }

    @GetMapping("/battle-config/list")
    public ResponseEntity<DictionaryResponse> battleConfigList(){
        return ResponseEntity.ok().body( metaDataService.getBattleConfigList());
    }

    @GetMapping("/battle-reward/list")
    public ResponseEntity<DictionaryResponse> battleRewardList(){
        return ResponseEntity.ok().body( metaDataService.getBattleRewardList());
    }

    @GetMapping("/game-mode/list")
    public ResponseEntity<DictionaryResponse> gameModeList(){
        return ResponseEntity.ok().body( metaDataService.getGameModeList());
    }

    @GetMapping("/event-action/list")
    public ResponseEntity<DictionaryResponse> eventActionList(){
        return ResponseEntity.ok().body( metaDataService.getEventActionList());
    }

    @GetMapping("/item/list")
    public ResponseEntity<DictionaryResponse> itemList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( metaDataService.getItemDictList(requestParams));
    }

    @GetMapping("/item/excel-export")
    public void itemExcelExport(HttpServletResponse response,
                                @RequestParam Map<String, String> requestParams){
        metaDataService.itemExcelExport(response, requestParams);
    }

    @GetMapping("/craft/list")
    public ResponseEntity<DictionaryResponse> craftList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( metaDataService.getCraftingDictList(requestParams));
    }

    @GetMapping("/craft/excel-export")
    public void craftExcelExport(HttpServletResponse response,
                                @RequestParam Map<String, String> requestParams){
        metaDataService.craftExcelExport(response, requestParams);
    }
}
