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.IAccountAgentDayService;
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.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;

@RestController
@RequestMapping("/promote")
public class AccountAgentDayController {
    @Autowired
    private IAccountAgentDayService accountAgentDayService;

    @PreAuthorize(permissionKey = "gameData:promote:day")
    @PostMapping("/day")
    public ResultVO<Page<GamePromoteDayVO>> accountAgentDay(@RequestBody GamePromoteDayDTO dto) {
        return ResultVO.ok(accountAgentDayService.accountAgentDay(dto));
    }

    @PreAuthorize(permissionKey = "gameData:promote:dayTotal")
    @PostMapping("/day/total")
    public ResultVO<GamePromoteDayTotalVO> accountAgentDayTotal(@RequestBody GamePromoteDayTotalDTO dto) {
        return ResultVO.ok(accountAgentDayService.accountAgentDayTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:promote:total")
    @PostMapping("/total")
    public ResultVO<Page<GamePromoteTotalVO>> accountAgentTotal(@RequestBody GamePromoteTotalDTO dto) {
        return ResultVO.ok(accountAgentDayService.accountAgentTotal(dto));
    }

    @PreAuthorize(permissionKey = "gameData:promote:totalSum")
    @PostMapping("/total/sum")
    public ResultVO<GamePromoteTotalSumVO> accountAgentTotalSum(@RequestBody GamePromoteTotalSumDTO dto) {
        return ResultVO.ok(accountAgentDayService.accountAgentTotalSum(dto));
    }

    @PreAuthorize(permissionKey = "gameData:accountAgent:again")
    @PostMapping("/again")
    public ResultVO<Map<LocalDate, List<AgentDayAgainVO>>> accountAgentDayAgain(@RequestBody AgentDayAgainDTO dto) throws Exception {
        return ResultVO.ok(accountAgentDayService.accountAgentDayAgain(dto));
    }
}
