package com.gyee.frame.controller.comm;


import com.gyee.frame.common.conf.AjaxStatus;
import com.gyee.frame.common.domain.AjaxResult;
import com.gyee.frame.model.custom.ServerMessage;
import com.gyee.frame.service.comm.FullPushMsgService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


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


    @Autowired
    private FullPushMsgService fullPushMsgService;


    private Logger logger = LoggerFactory.getLogger(WebSocketController.class);

    @SubscribeMapping("/submsg")
    public ServerMessage sub() {
        logger.info("用户订阅了消息推送。。。");
        return new ServerMessage("订阅成功。");
    }


    /**
     * 推送消息
     *
     * @return
     */
    @GetMapping("/pushmsg")
    @ResponseBody
    @ApiOperation(value = "推送全场重要信息", notes = "推送全场重要信息")
    public AjaxResult pushmsg() {

        Map<String, Object> result = fullPushMsgService.addPushMsg();


        return AjaxResult.successData(AjaxStatus.success.code, result);
    }
}

