package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.response.IndicatorsResponse;
import com.caliverse.admin.domain.service.IndicatorsService;

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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Tag(name = "유저지표", description = "유저지표 api")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/indicators")
public class IndicatorsController {
    private final IndicatorsService indicatorsService;

    @GetMapping("/user/list")
    public ResponseEntity<IndicatorsResponse> userlist(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.list(requestParams));
    }

    @GetMapping("/user/total")
    public ResponseEntity<IndicatorsResponse> total(){
        return ResponseEntity.ok().body( indicatorsService.total());
    }

    @GetMapping("/user/excel-down")
    public void userExcelDown(
            @RequestParam Map<String, String> requestParams, HttpServletResponse res){
        indicatorsService.userExcelDown(requestParams, res);
    }
    //Retention
    @GetMapping("/retention/list")
    public ResponseEntity<IndicatorsResponse> retentionList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.retentionList(requestParams));
    }
    //Retention
    @GetMapping("/retention/excel-down")
    public void retentionExcelDown(
            @RequestParam Map<String, String> requestParams,HttpServletResponse res){
        indicatorsService.retentionExcelDown(requestParams,res);
    }
    //Segment
    @GetMapping("/segment/list")
    public ResponseEntity<IndicatorsResponse> segmentList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.segmentList(requestParams));
    }
    @GetMapping("/segment/excel-down")
    public void segmentExcelDown(
            @RequestParam Map<String, String> requestParams,HttpServletResponse res){
        indicatorsService.segmentExcelDown(requestParams, res);
    }
    //Playtime
    @GetMapping("/playtime/list")
    public ResponseEntity<IndicatorsResponse> playTimeList(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.playTimeList(requestParams));
    }
    @GetMapping("/playtime/excel-down")
    public void playTimeExcelDown(
            @RequestParam Map<String, String> requestParams,HttpServletResponse res){
        indicatorsService.playTimeExcelDown(requestParams, res);
    }

    // 재화 지표
    @GetMapping("/currency/use")
    public ResponseEntity<IndicatorsResponse> acquire(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getCurrencyUse(requestParams));
    }
    @GetMapping("/currency/excel-down")
    public void currencyExcelDown(
            @RequestParam Map<String, String> requestParams, HttpServletResponse res){
        indicatorsService.currencyExcelDown(requestParams, res);
    }

    // VBP 지표
    @GetMapping("/currency/vbp")
    public ResponseEntity<IndicatorsResponse> vbp(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getVBPList(requestParams));
    }
    // Item 지표
    @GetMapping("/currency/item")
    public ResponseEntity<IndicatorsResponse> item(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getItemList(requestParams));
    }
    // 인스턴스 지표
    @GetMapping("/currency/instance")
    public ResponseEntity<IndicatorsResponse> instance(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getInstanceList(requestParams));
    }
    // 의상/타투 지표
    @GetMapping("/currency/clothes")
    public ResponseEntity<IndicatorsResponse> clothes(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getClothesList(requestParams));
    }

    // DAU 지표
    @GetMapping("/dau/list")
    public ResponseEntity<IndicatorsResponse> dau(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getDauDataList(requestParams));
    }

    @GetMapping("/dau/excel-down")
    public void dauExcelDown(
            @RequestParam Map<String, String> requestParams,HttpServletResponse res){
        indicatorsService.dauExcelDown(requestParams, res);
    }


    /*
    // DAU 지표
    @GetMapping("/daily-medal/list")
    public ResponseEntity<IndicatorsResponse> dailyMedal(
            @RequestParam Map<String, String> requestParams){
        return ResponseEntity.ok().body( indicatorsService.getDailyMedalDataList(requestParams));
    }

    @GetMapping("/daily-medal/excel-down")
    public void dailyMedalExcelDown(
            @RequestParam Map<String, String> requestParams,HttpServletResponse res){
        indicatorsService.dailyMedalExcelDown(requestParams, res);
    }
     */
}
