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

import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.data.serve.pojo.dto.AdsAccountRechargeRankingListDTO;
import com.zanxiang.game.data.serve.pojo.dto.AdsAgentRechargeRankingListDTO;
import com.zanxiang.game.data.serve.pojo.dto.RechargeRankingDTO;
import com.zanxiang.game.data.serve.pojo.vo.AdsAccountRechargeRankingVO;
import com.zanxiang.game.data.serve.pojo.vo.AdsAgentRechargeRankingVO;
import com.zanxiang.game.data.serve.pojo.vo.GameRechargeRankingVO;
import com.zanxiang.game.data.serve.pojo.vo.PlayerRechargeRankingVO;
import com.zanxiang.game.data.serve.service.IAdsAccountRechargeRankingService;
import com.zanxiang.game.data.serve.service.IAdsAgentRechargeRankingService;
import com.zanxiang.game.data.serve.service.IRankingService;
import com.zanxiang.game.data.serve.utils.Page;
import com.zanxiang.module.util.pojo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

@RestController
@RequestMapping("/ranking")
public class RankingController {
    @Autowired
    private IRankingService rankingService;

    @Autowired
    private IAdsAccountRechargeRankingService adsAccountRechargeRankingService;
    @Autowired
    private IAdsAgentRechargeRankingService adsAgentRechargeRankingService;

    @PreAuthorize(permissionKey = "gameData:ranking:game")
    @PostMapping("/game")
    public ResultVO<Page<GameRechargeRankingVO>> gameRanking(@RequestBody RechargeRankingDTO dto) {
        return ResultVO.ok(rankingService.gameRanking(dto));
    }

    @PreAuthorize(permissionKey = "gameData:ranking:player")
    @PostMapping("/player")
    public ResultVO<Page<PlayerRechargeRankingVO>> playerRanking(@RequestBody RechargeRankingDTO dto) {
        return ResultVO.ok(rankingService.playerRanking(dto));
    }

    @PreAuthorize(permissionKey = "gameData:ranking:agent")
    @PostMapping("/agent")
    public ResultVO<Page<AdsAgentRechargeRankingVO>> agent(@Validated @RequestBody AdsAgentRechargeRankingListDTO dto) {
        return ResultVO.ok(adsAgentRechargeRankingService.listOfPage(dto));
    }

    @PreAuthorize(permissionKey = "gameData:ranking:account")
    @PostMapping("/account")
    public ResultVO<Page<AdsAccountRechargeRankingVO>> account(@Validated @RequestBody AdsAccountRechargeRankingListDTO dto) {
        return ResultVO.ok(adsAccountRechargeRankingService.listOfPage(dto));
    }
}
