package cn.reghao.tnb.content.app.vod.controller;

import cn.reghao.jutil.web.WebResult;
import cn.reghao.tnb.common.auth.AuthUser;
import cn.reghao.tnb.content.app.vod.service.WatchAnalysisService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author reghao
 * @date 2023-08-27 19:12:45
 */
@Tag(name = "用户观看视频分析接口")
@RestController
@RequestMapping("/api/content/video/analysis")
public class WatchAnalysisController {
    private final WatchAnalysisService watchAnalysisService;

    public WatchAnalysisController(WatchAnalysisService watchAnalysisService) {
        this.watchAnalysisService = watchAnalysisService;
    }

    @AuthUser
    @Operation(summary = "用户最近一周观看视频时长统计", description = "N")
    @GetMapping(value = "/watch", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getExamCount() {
        List<String> list = watchAnalysisService.getLineChartData();
        return WebResult.success(list);
    }

    @AuthUser
    @Operation(summary = "用户最近一周观看视频分区统计", description = "N")
    @GetMapping(value = "/watch/region", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getExamPassRate() {
        List<String> list = watchAnalysisService.getPieChartData();
        return WebResult.success(list);
    }
}
