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

import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.data.serve.pojo.dto.PlayerBannedListDTO;
import com.zanxiang.game.data.serve.pojo.dto.PlayerDataListDTO;
import com.zanxiang.game.data.serve.pojo.dto.PlayerLoginLogDataListDTO;
import com.zanxiang.game.data.serve.pojo.dto.PlayerRoleDataListDTO;
import com.zanxiang.game.data.serve.pojo.vo.PlayerDataVO;
import com.zanxiang.game.data.serve.pojo.vo.PlayerRoleDataVO;
import com.zanxiang.game.data.serve.service.IPlayerDataService;
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.util.Map;

/**
 * @author tianhua
 * @time 2023/9/6
 * @Description 玩家数据控制层
 **/
@RestController
@RequestMapping("/player")
@Slf4j
public class PlayerDataController {

    @Autowired
    private IPlayerDataService playerDataService;

    @PreAuthorize(permissionKey = "playerData:player:list")
    @PostMapping("/list")
    public ResultVO<Page<PlayerDataVO>> getPlayerDataList(@RequestBody PlayerDataListDTO dto) {
        return ResultVO.ok(playerDataService.getPlayerDataList(dto));
    }

    @PreAuthorize(permissionKey = "playerData:role:list")
    @PostMapping("/role/list")
    public ResultVO<Page<PlayerRoleDataVO>> getPlayerRoleDataList(@RequestBody PlayerRoleDataListDTO dto) {
        return ResultVO.ok(playerDataService.getPlayerRoleDataList(dto));
    }

    @PreAuthorize(permissionKey = "playerData:role:total")
    @PostMapping("/role/total")
    public ResultVO<PlayerRoleDataVO> getPlayerRoleTotalData(@RequestBody PlayerRoleDataListDTO dto) {
        return ResultVO.ok(playerDataService.getPlayerRoleTotalData(dto));
    }

    @PreAuthorize(permissionKey = "playerData:player:loginLog")
    @PostMapping("/login/list")
    public ResultVO<Page<Map>> getPlayerLoginLogDataList(@RequestBody PlayerLoginLogDataListDTO dto) {
        return ResultVO.ok(playerDataService.getPlayerLoginLogDataList(dto));
    }

    @PreAuthorize(permissionKey = "playerData:player:banned")
    @PostMapping("/banned/list")
    public ResultVO<Page<Map>> getPlayerBannedDataList(@RequestBody PlayerBannedListDTO dto) {
        return ResultVO.ok(playerDataService.getPlayerBannedDataList(dto));
    }

}
