package com.nokia.controller;

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 com.nokia.common.http.R;
import com.nokia.pojo.TousuSheet;
import com.nokia.service.EsbNettyService;

@RestController
@RequestMapping("/esb/socket")
public class EsbSocketController {

    private final EsbNettyService esbNettyService;

    public EsbSocketController(EsbNettyService esbNettyService) {
        this.esbNettyService = esbNettyService;
    }

    @PostMapping("/send/toususheet")
    public R sendTousuSheet(@RequestBody TousuSheet tousuSheet) {
        try {
            esbNettyService.send(tousuSheet);
            return R.ok().message("发送成功。");
        } catch (Exception e) {
            return R.error().message(e.getMessage());
        }
    }
}
