package com.usky.ai.controller.web;


import com.usky.ai.dto.BoardPingDTO;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@RestController
@RequestMapping("/api/heartbeat")
public class BoardPingController {

    // 每个 BoardId 最新一条心跳
    public static final Map<String, BoardPingDTO> CACHE = new ConcurrentHashMap<>();

    /**
     * 返回全部设备最新心跳
     */
    @GetMapping
    public Map<String, BoardPingDTO> all() {
        return CACHE;
    }

    /**
     * 返回指定设备最新心跳
     */
    @GetMapping("/{boardId}")
    public BoardPingDTO one(@PathVariable String boardId) {
        return CACHE.get(boardId);
    }
}
