package com.usky.agbox.controller.web;


import com.alibaba.fastjson.JSONObject;
import com.usky.agbox.service.job.patrolAgbox;
import com.usky.common.core.bean.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * @author han
 * @date 2024/03/22 16:20
 */
@RestController
@RequestMapping("/patrolAgbox")
public class patrolAgboxController {

    @Autowired
    private patrolAgbox agBox;

    /**
     * 获取事件编码信息
     * @return
     */
    @PostMapping("/getEventCode")
    public ApiResult<JSONObject> getEventCode(){
        return ApiResult.success(agBox.getEventCode());
    }

    /**
     * 获取设备列表信息
     * @return
     */
    @PostMapping("/getDeviceList")
    public ApiResult<JSONObject> getDeviceList(){
        return ApiResult.success(agBox.getDeviceList());
    }

    /**
     * 添加事件信息
     * @return
     */
    @PostMapping("/addEvent")
    public ApiResult<JSONObject> addEvent(@RequestBody String requestBody){
        return ApiResult.success(agBox.addEvent(requestBody));
    }

    /**
     * 更新心跳信息
     * @return
     */
    @PostMapping("/updateHeart")
    public ApiResult<JSONObject> updateHeart(@RequestBody String requestBody){
        return ApiResult.success(agBox.updateHeart(requestBody));
    }

    /**
     * 获取事件信息
     * @return
     */
    @PostMapping("/getEvent")
    public ApiResult<JSONObject> getEvent(@RequestBody String requestBody){
        return ApiResult.success(agBox.getEvent(requestBody));
    }
}
