package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.request.LogGameRequest;
import com.caliverse.admin.domain.request.LogGenericRequest;
import com.caliverse.admin.domain.response.IndicatorsResponse;
import com.caliverse.admin.domain.response.LogResponse;
import com.caliverse.admin.domain.service.LogService;
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/log")
public class LogController {
    private final LogService logService;

    @PostMapping("/generic/list")
    public ResponseEntity<LogResponse> genericlist(
            @RequestBody LogGenericRequest logGenericRequest){
        return ResponseEntity.ok().body( logService.genericLogList(logGenericRequest));
    }

    @PostMapping("/generic/excel-export")
    public void excelExport(HttpServletResponse response,
                                                   @RequestBody LogGenericRequest logGenericRequest){
        logService.genericExcelExport(response, logGenericRequest);
    }

    @GetMapping("/progress/{taskId}")
    public ResponseEntity<Map<String, Object>> getProgress(@PathVariable String taskId) {
        return ResponseEntity.ok().body(logService.getProgress(taskId));
    }

    @GetMapping("/currency/list")
    public ResponseEntity<LogResponse> currencyList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getCurrencyLogList(requestParams));
    }

    @GetMapping("/currency/detail/list")
    public ResponseEntity<LogResponse> currencyDetailList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getCurrencyDetailLogList(requestParams));
    }

    @PostMapping("/currency/detail/excel-export")
    public void currencyDetailExcelExport(HttpServletResponse response,
                            @RequestBody LogGameRequest logGameRequest){
        logService.currencyDetailExcelExport(response, logGameRequest);
    }

    @PostMapping("/currency/excel-export")
    public void currencyExcelExport(HttpServletResponse response,
                                          @RequestBody LogGameRequest logGameRequest){
        logService.currencyExcelExport(response, logGameRequest);
    }

    @GetMapping("/item/detail/list")
    public ResponseEntity<LogResponse> itemDetailList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getItemDetailLogList(requestParams));
    }

    @PostMapping("/item/detail/excel-export")
    public void itemDetailExcelExport(HttpServletResponse response,
                                          @RequestBody LogGameRequest logGameRequest){
        logService.itemDetailExcelExport(response, logGameRequest);
    }

    @GetMapping("/currency-item/list")
    public ResponseEntity<LogResponse> currencyItemList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getCurrencyItemLogList(requestParams));
    }

    @PostMapping("/currency-item/excel-export")
    public void currencyItemExcelExport(HttpServletResponse response,
                                      @RequestBody LogGameRequest logGameRequest){
        logService.currencyItemExcelExport(response, logGameRequest);
    }

    @GetMapping("/user/create/list")
    public ResponseEntity<LogResponse> userCreateList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getUserCreateLogList(requestParams));
    }

    @PostMapping("/user/create/excel-export")
    public void userCreateExcelExport(HttpServletResponse response,
                                        @RequestBody LogGameRequest logGameRequest){
        logService.userCreateExcelExport(response, logGameRequest);
    }

    @GetMapping("/user/login/list")
    public ResponseEntity<LogResponse> userLoginList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getUserLoginDetailLogList(requestParams));
    }

    @PostMapping("/user/login/excel-export")
    public void userLoginExcelExport(HttpServletResponse response,
                                        @RequestBody LogGameRequest logGameRequest){
        logService.userLoginExcelExport(response, logGameRequest);
    }

    @GetMapping("/user/snapshot/list")
    public ResponseEntity<LogResponse> snapshotList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( logService.getSnapshotLogList(requestParams));
    }

    @PostMapping("/user/snapshot/excel-export")
    public void userSnapshotExcelExport(HttpServletResponse response,
                                     @RequestBody LogGameRequest logGameRequest){
        logService.SnapshotExcelExport(response, logGameRequest);
    }
}
