DataController.java
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.viontech.controller;
import com.viontech.model.BaseModel;
import com.viontech.netty.ChannelGroup;
import com.viontech.process.ProcessService;
import com.viontech.utils.VideoUtil;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.annotation.Resource;
import java.io.IOException;
/**
* .
*
* @author 谢明辉
* @date 2020/8/18
*/
@RestController
@Slf4j
public class DataController {
@Resource
private ProcessService processService;
@PostMapping("/data")
public Object receiveData(@RequestBody String dataStr) throws Exception {
BaseModel data = processService.process(dataStr);
if (data != null) {
ChannelGroup.broadcast(data);
}
return "success";
}
@PostMapping("/video")
public Object receiveVideo(@RequestParam(name = "file") MultipartFile file, MultipartHttpServletRequest request) throws IOException {
log.info("接收到视频文件");
log.warn("接收到视频文件");
String refid = request.getParameter("refid");
VideoUtil.addVideo(refid, file.getBytes());
return "success";
}
}