package thyyxxk.webserver.controller.webosket;

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;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.constants.Message;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.utils.SocketMsg;
import thyyxxk.webserver.websocket.WebSocketServer;

@RestController
@RequestMapping("/socketMessage")
public class SendSocketController {

    @PassToken
    @PostMapping("/sendById")
    public String sendMessageById(@RequestBody CodeName msg) {
        WebSocketServer.sendMessage(msg.getCode(), SocketMsg.socketVo(Message.MED_INS_FEE_UPLOAD_PROGRESS, msg.getName()));
        return "done";
    }
}
