package com.mosty.websocket.controller;

import com.mosty.base.model.dto.websocket.WebSocketObject;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.websocket.service.WebSocketService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "websocket推送线管")
@RestController
@AllArgsConstructor
@RequestMapping("/socket")
public class WebSocketController {

    private final WebSocketService webSocketService;

    @ApiOperation("向用户发送消息")
    @PostMapping(value = "sendMessage")
    public ResponseResult<Void> sendMessage(@RequestBody WebSocketObject obj) {
        this.webSocketService.sendInfo(obj);
        return ResponseResult.success();
    }

    @ApiOperation("向用户发送报备数据")
    @PostMapping(value = "sendBbMessage")
    public ResponseResult<Void> sendBbMessage(@RequestBody WebSocketObject obj) {
        this.webSocketService.sendBbMessage(obj);
        return ResponseResult.success();
    }
}
