DataController.java 909 Bytes
package com.viontech.controller;

import com.viontech.model.BaseModel;
import com.viontech.netty.ChannelGroup;
import com.viontech.process.ProcessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * .
 *
 * @author 谢明辉
 * @date 2020/8/18
 */
@RestController
@Slf4j
public class DataController {

    @Resource
    private ProcessService processService;

    @PostMapping("/data")
    public Object receiveData(@RequestBody String dataStr) throws Exception {
        log.info("收到一条繁星发来的消息");
        BaseModel data = processService.process(dataStr);
        if (data != null) {
            ChannelGroup.broadcast(data);
        }
        return "success";
    }


}