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

import com.mybatisflex.core.row.Row;
import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.gs.data.serve.pojo.dto.*;
import com.zanxiang.game.gs.data.serve.pojo.vo.*;
import com.zanxiang.game.gs.data.serve.service.IAdsGsServerDayParentService;
import com.zanxiang.game.gs.data.serve.service.IAdsRoleAmountDataParentService;
import com.zanxiang.game.gs.data.serve.service.IAdsRoleAmountRateParentService;
import com.zanxiang.game.gs.data.serve.service.IAdsServerRankingParentService;
import com.zanxiang.module.util.pojo.ResultVO;
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;

import javax.annotation.Resource;

@RestController
@RequestMapping("/game/parent")
public class GameParentController {
    @Resource
    private IAdsRoleAmountDataParentService adsRoleAmountDataParentService;
    @Resource
    private IAdsRoleAmountRateParentService adsRoleAmountRateParentService;
    @Resource
    private IAdsGsServerDayParentService gsServerDayParentService;
    @Resource
    private IAdsServerRankingParentService serverRankingParentService;

    @PreAuthorize(permissionKey = "gameGs:bigR:list")
    @PostMapping("/bigR/listOfPage")
    public ResultVO<PageVO<BigRVO, Row>> bigRListOfPage(@Validated @RequestBody BigRDTO dto) {
        return ResultVO.ok(adsRoleAmountDataParentService.bigRListOfPage(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:rolePay:list")
    @PostMapping("/role/pay/retained/listOfPage")
    public ResultVO<PageVO<RolePayVO, Row>> rolePay(@Validated @RequestBody RolePayDTO dto) {
        return ResultVO.ok(adsRoleAmountRateParentService.rolePayOfPage(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:rolePay:total")
    @PostMapping("/role/pay/retained/total")
    public ResultVO<RolePayVO> rolePayTotal(@Validated @RequestBody RolePayDTO dto) {
        return ResultVO.ok(adsRoleAmountRateParentService.rolePayTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:serverPay:list")
    @PostMapping("/server/pay/retained/listOfPage")
    public ResultVO<PageVO<ServerPayVO, Row>> serverPay(@Validated @RequestBody ServerPayDTO dto) {
        return ResultVO.ok(gsServerDayParentService.serverPay(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:serverPay:total")
    @PostMapping("/server/pay/retained/total")
    public ResultVO<ServerPayVO> serverPayTotal(@Validated @RequestBody ServerPayDTO dto) {
        return ResultVO.ok(gsServerDayParentService.serverPayTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:roleRemoveGame:monitor")
    @PostMapping("/role/remove/game/monitor")
    public ResultVO<PageVO<RoleRemoveGameMonitorVO, Row>> roleRemoveGameMonitor(@Validated @RequestBody RoleRemoveGameMonitorDTO dto) {
        return ResultVO.ok(adsRoleAmountDataParentService.roleRemoveGameMonitor(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:role:manage")
    @PostMapping("/role/manage")
    public ResultVO<PageVO<RoleManageVO, Row>> roleManage(@Validated @RequestBody RoleManageDTO dto) {
        return ResultVO.ok(adsRoleAmountDataParentService.roleManage(dto));
    }

    @PreAuthorize(permissionKey = "gameGs:serve:manage")
    @PostMapping("/serve/manage")
    public ResultVO<PageVO<ServeManageVO, Row>> serveManage(@Validated @RequestBody ServeManageDTO dto) {
        return ResultVO.ok(serverRankingParentService.serveManage(dto));
    }

}
