package com.shzg.project.worn.controller;

import com.shzg.project.worn.websocket.manager.WebSocketSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ws/test")
public class WebSocketTestController {

    @Autowired
    private WebSocketSessionManager sessionManager;

    /**
     * 测试推送（广播）
     */
    @GetMapping("/broadcast")
    public String broadcast() {
        sessionManager.sendAll("🔥 测试广播消息");
        return "OK";
    }

    /**
     * 测试按dept推送
     */
    @GetMapping("/dept/{deptId}")
    public String sendToDept(@PathVariable Long deptId) {
        sessionManager.sendToDept(deptId, "📦 这是dept推送消息");
        return "OK";
    }
}