CommandController.java 1.4 KB
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);
    }

}