MonitorController.java 1.88 KB
package vion.controller.mqtt;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.monitor.OrgDTO;
import vion.model.monitor.Agent;
import vion.model.monitor.AgentRecord;
import vion.model.monitor.ServiceRecord;
import vion.model.monitor.Upgrade;
import vion.service.monitor.IAgentService;

import java.util.List;

/**
 * @author vion
 * @date 2024/10/16
 */
@RestController
@RequestMapping("/api/monitor")
@RequiredArgsConstructor
public class MonitorController {

    private final IAgentService agentService;

    /**
     * Agent 注册
     *
     * @param agent agent自身信息
     * @return java.lang.String
     */
    @PostMapping("/reg")
    public String reg(@RequestBody Agent agent) {
        return agentService.reg(agent);
    }

    /**
     * Agent 获取升级包信息
     *
     * @param type 1:store 2:mall
     * @return Upgrade  升级包信息
     */
    @GetMapping("/upgrade")
    public Upgrade getUpgradeInfo(Short type) {
        return agentService.getUpgradeInfo(type);
    }

    /**
     * Agent 发送服务器信息
     *
     * @param agentRecord 服务器相关信息
     * @return java.lang.String
     */
    @PostMapping("/server")
    public String recServerInfo(@RequestBody AgentRecord agentRecord) {
        return agentService.recAgentRecord(agentRecord);
    }

    /**
     * Agent 发送服务状态
     *
     * @param recList 服务状态
     * @return java.lang.String
     */
    @PostMapping("/service")
    public String recServiceInfo(@RequestBody List<ServiceRecord> recList) {
        return agentService.recServiceInfo(recList);
    }

    /**
     * Agent 发送组织关系
     *
     * @param orgDTO account、mall
     * @return java.lang.String
     */
    @PostMapping("/org")
    public String recOrgInfo(@RequestBody OrgDTO orgDTO) {
        return agentService.recOrgInfo(orgDTO);
    }
}