package com.example.demo01.controller;

import com.example.demo01.common.result.Result;
import com.example.demo01.entity.Player;
import com.example.demo01.service.PlayerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/player")
public class PlayerController {

    @Autowired
    private PlayerService playerService;

    // 获取玩家当前面板状态：GET /api/player/status?id=1
    @GetMapping("/status")
    public Result<Player> getStatus(@RequestParam Long id) {
        Player player = playerService.getPlayerStatus(id);
        if (player == null) {
            return Result.error("未找到该角色");
        }
        return Result.success(player);
    }
}