package com.zanxiang.game.data.serve.controller;

import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.data.serve.pojo.dto.*;
import com.zanxiang.game.data.serve.pojo.vo.*;
import com.zanxiang.game.data.serve.service.IActiveDataService;
import com.zanxiang.game.data.serve.service.IGameDataService;
import com.zanxiang.game.data.serve.utils.Page;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * @author tianhua
 * @time 2023/7/12
 * @Description 游戏数据控制层接口
 **/
@RestController
@RequestMapping("/gameData")
@Slf4j
public class GameDataController {

    @Autowired
    private IGameDataService gameDataService;
    @Autowired
    private IActiveDataService activeDataService;

    @PreAuthorize(permissionKey = "gameData:adsGameDay:day")
    @PostMapping("/day")
    public ResultVO<Page<GameDataDayVO>> getGameDataDay(@RequestBody GameDataDayDTO dto) {
        return ResultVO.ok(gameDataService.getGameDataDay(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:dayTotal")
    @PostMapping("/day/total")
    public ResultVO<GameDataDayTotalVO> getGameDataDay(@RequestBody GameDataDayTotalDTO dto) {
        return ResultVO.ok(gameDataService.getGameDataDayTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:total")
    @PostMapping("/total")
    public ResultVO<Page<GameDataTotalVO>> getGameDataTotal(@RequestBody GameDataTotalDTO dto) {
        return ResultVO.ok(gameDataService.getGameDataTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:totalSum")
    @PostMapping("/total/sum")
    public ResultVO<GameDataTotalTotalVO> getGameDataTotalTotal(@RequestBody GameDataTotalTotalDTO dto) {
        return ResultVO.ok(gameDataService.getGameDataTotalTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:h5")
    @PostMapping("/h5")
    public ResultVO<Page<GameDataH5VO>> getH5Recharge(@RequestBody GameDataH5DTO dto) {
        return ResultVO.ok(gameDataService.getH5Recharge(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:water")
    @PostMapping("/water")
    public ResultVO<Page<GameDataWaterVO>> getGameDataWater(@RequestBody GameDataWaterDTO dto) {
        return ResultVO.ok(gameDataService.getGameDataWater(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:again")
    @PostMapping("/again")
    public ResultVO<Map<LocalDate, List<GameDataAgainDayVO>>> getGameDataAgainDay(@RequestBody GameDataAgainDayDTO dto) throws Exception {
        return ResultVO.ok(gameDataService.getGameDataAgainDay(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:ltv")
    @PostMapping("/ltv")
    public ResultVO<Page<LtvDataVO>> getLtvData(@RequestBody LtvDataDTO dto) {
        return ResultVO.ok(gameDataService.getLtvData(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:ltvTotal")
    @PostMapping("/ltv/total")
    public ResultVO<LtvDataTotalVO> getLtvDataTotal(@RequestBody LtvDataTotalDTO dto) {
        return ResultVO.ok(gameDataService.getLtvTotalData(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:firstNewUserAgain")
    @PostMapping("/firstNewUser/again")
    public ResultVO<Page<GameDataFirstNewUserAgainVO>> getFirstNewUserAgain(@RequestBody GameDataFirstNewUserAgainDTO dto) {
        return ResultVO.ok(gameDataService.getFirstNewUserAgain(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:firstNewUserAgainTotal")
    @PostMapping("/firstNewUser/again/total")
    public ResultVO<GameDataFirstNewUserAgainTotalVO> getFirstNewUserAgainTotal(@RequestBody GameDataFirstNewUserAgainTotalDTO dto) {
        return ResultVO.ok(gameDataService.getFirstNewUserAgainTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:adsGameDay:userDetails")
    @PostMapping("/user/details")
    public ResultVO<Page<GameDataUserDetailsVO>> getUserDetails(@RequestBody GameDataUserDetailsDTO dto) {
        return ResultVO.ok(gameDataService.getUserDetails(dto));
    }

    @PreAuthorize(permissionKey = "gameData:activeDay:activeDay")
    @PostMapping("/activeData/day")
    public ResultVO<Page<ActiveDataDayVO>> getActiveDataDay(@RequestBody ActiveDataDayDTO dto) {
        return ResultVO.ok(activeDataService.getActiveDataDay(dto));
    }

    @PreAuthorize(permissionKey = "gameData:activeDay:activeTotal")
    @PostMapping("/activeData/total")
    public ResultVO<ActiveDataTotalVO> getActiveDataTotal(@RequestBody ActiveDataTotalDTO dto) {
        return ResultVO.ok(activeDataService.getActiveDataTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:activeData:activeMonth")
    @PostMapping("/activeData/month")
    public ResultVO<Page<ActiveDataMonthVO>> getActiveDataMonth(@RequestBody ActiveDataDayDTO dto) {
        return ResultVO.ok(activeDataService.getActiveDataMonth(dto));
    }

    @PreAuthorize(permissionKey = "gameData:activeData:activeMonthTotal")
    @PostMapping("/activeData/monthTotal")
    public ResultVO<ActiveDataMonthTotalVO> getActiveMonthDataTotal(@RequestBody ActiveDataTotalDTO dto) {
        return ResultVO.ok(activeDataService.getActiveMonthDataTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:media:activeDay")
    @PostMapping("/mediaActiveData/day")
    public ResultVO<Page<MediaActiveDataDayVO>> getMediaActiveDataDay(@RequestBody MediaActiveDataDayDTO dto) {
        return ResultVO.ok(activeDataService.getMediaActiveDataDay(dto));
    }

    @PreAuthorize(permissionKey = "gameData:media:activeTotal")
    @PostMapping("/mediaActiveData/total")
    public ResultVO<MediaActiveDataTotalVO> getMediaActiveDataTotal(@RequestBody MediaActiveDataDayDTO dto) {
        return ResultVO.ok(activeDataService.getMediaActiveDataTotal(dto));
    }
    @PreAuthorize(permissionKey = "gameData:flow:monitor")
    @PostMapping("/flow/monitor")
    public ResultVO<Page<FlowMonitorVO>> getFlowMonitor(@RequestBody FlowMonitorDTO dto) {
        return ResultVO.ok(gameDataService.getFlowMonitor(dto));
    }

    @PreAuthorize(permissionKey = "gameData:flow:monitorCount")
    @PostMapping("/flow/monitorCount")
    public ResultVO<FlowMonitorCountVo> getFlowMonitorCount(@RequestBody FlowMonitorDTO dto) {
        return ResultVO.ok(gameDataService.getFlowMonitorCount(dto));
    }





}
