package com.fs;

import com.alibaba.fastjson.JSONObject;
import com.fs.websocket.WebSocketServer;
import com.fs.websocket.bean.MsgBean;
import com.fs.websocket.bean.RestBean;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IMController {
    Logger logger= LoggerFactory.getLogger(getClass());

    @Autowired
    WebSocketServer webSocketServer;

    @PostMapping("/sendInfo")
    public void sendOrderFinish(HttpServletRequest request,
                                @RequestBody RestBean param){
        try {
            webSocketServer.sendInfo(param.getId(), param.getMessage());
            logger.info("发送预警：{}",param.getId()+param.getMessage());

        } catch (Exception e) {

        }
    }

}
