CommandController.java
1.4 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
package com.neotel.smf.command.rest;
import com.neotel.smf.command.bean.CommonBean;
import com.neotel.smf.command.bean.ResultBean;
import com.neotel.smf.command.data.DataCache;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/smf/rest/api")
public class CommandController {
/**
* 接受指定
*
* @param commonBean
* @return
*/
@PostMapping("/opDeviceIo")
public ResultBean opDeviceIo(@RequestBody CommonBean commonBean) {
log.info("{}收到数据为:{}", "opDeviceIo", commonBean.toString());
DataCache.putOp(commonBean.getOpKey(), commonBean.getValue());
return ResultBean.newOkResult("");
}
/**
* 获取指定
*
* @param commonBean
* @return
*/
@PostMapping("/getStatus")
public ResultBean getStatus(@RequestBody CommonBean commonBean) {
log.info("{}收到数据为:{}", "getStatus", commonBean.toString());
Integer opValue = DataCache.getOpValue(commonBean.getOpKey());
log.info("{}获取到的指令为:{}", commonBean.getOpKey(), opValue);
return ResultBean.newOkResult(opValue);
}
}