package cn.sikey.websocket.controller.app.message;

import cn.sikey.framework.common.pojo.CommonResult;
import cn.sikey.websocket.controller.app.message.vo.MessagingPublishReqVO;
import cn.sikey.websocket.controller.app.message.vo.MessagingPublishRespVO;
import cn.sikey.websocket.service.MessagingPublishService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
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;

/**
 * @Author: nelson
 * @Date: 2025/5/30
 * @Description: 消息
 */
@RestController
@RequestMapping("/websocket/app/messaging/publish")
public class MessageController {

    @Resource
    private MessagingPublishService messagingPublishService;

    /**
     * 测试消息
     *
     * @param request 请求
     * @return
     */
    @PostMapping("/test")
    public CommonResult test(@Validated @RequestBody MessagingPublishReqVO<MessagingPublishReqVO.TestContent> request) {
        MessagingPublishRespVO messagingPublishRespVO = messagingPublishService.publish(request);
        return CommonResult.success(messagingPublishRespVO);
    }
}
