package com.zanxiang.game.module.manage.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zanxiang.erp.security.annotation.PreAuthorize;
import com.zanxiang.game.module.manage.pojo.params.GameUserChatListParam;
import com.zanxiang.game.module.manage.pojo.vo.GameUserChatVO;
import com.zanxiang.game.module.manage.service.IGameUserChatService;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author : lingfeng
 * @time : 2025-03-13
 * @description : 游戏聊天记录
 */
@RestController
@RequestMapping("/game/chat")
@Slf4j
public class GameUserChatController {

    @Autowired
    private IGameUserChatService gameUserChatService;

    @GetMapping(value = "/game/list")
    @PreAuthorize(permissionKey = "manage:gameChat:gameList")
    public ResultVO<Map<Long, String>> chatGameMap() {
        return ResultVO.ok(gameUserChatService.chatGameMap());
    }

    @GetMapping(value = "/game/server/list")
    @PreAuthorize(permissionKey = "manage:gameChat:gameServerList")
    public ResultVO<Map<String, String>> chatGameServerMap(@RequestParam Long supperGameId) {
        return ResultVO.ok(gameUserChatService.chatGameServerMap(supperGameId));
    }

    @PostMapping(value = "/list")
    @PreAuthorize(permissionKey = "manage:gameChat:chatList")
    public ResultVO<IPage<GameUserChatVO>> listOfPage(@Validated @RequestBody GameUserChatListParam param) {
        return ResultVO.ok(gameUserChatService.listOfPage(param));
    }
}
