package com.zehong.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.zehong.system.domain.TEventReceive;
import com.zehong.system.service.ITEventReceiveService;
import com.zehong.system.service.WebSocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.RestController;

import java.util.List;

@RestController
@RequestMapping("/websocket")
public class WebSocketController {

    private static final Logger log = LoggerFactory.getLogger(WebSocketController.class);

    @Autowired
    private WebSocketServer webSocketServer;
    @Autowired
    private ITEventReceiveService tEventReceiveService;

    @GetMapping("/send")
    public void send(Integer enterpriseId){
        try {
            //List<TEventReceive> list = tEventReceiveService.getReadReceiveList( enterpriseId);
            webSocketServer.batchSendMessage(JSONObject.toJSONString("success"));
        } catch (Exception e) {
            log.error("wesocket发送失败！");
        }

    }
}
